
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
cache-ts
is a straightforward cache implementation for TypeScript, extending the native Map object. It provides a simple and efficient way to manage key-value pairs with a specified capacity, automatically handling entries based on their usage.
npm install cache-ts
# or
yarn add cache-ts
import { Cache } from 'cache-ts';
// Create a cache with a maximum capacity of 100 entries
const myCache = new Cache<string, number>(100);
// Set a key-value pair in the cache
myCache.set('key1', 42);
// Retrieve the value associated with a key
const value = myCache.get('key1');
constructor(capacity: number)
Creates a new Cache
instance with a specified capacity.
const myCache = new Cache<string, number>(100);
set(key: TKey, value: TValue): Cache<TKey, TValue>
Adds or updates a key-value pair in the cache. Automatically handles eviction if the cache reaches its capacity.
myCache.set('key1', 42);
get(key: TKey): TValue | undefined
Retrieves the value associated with a key from the cache. If the key exists, it is promoted to the most recently used entry.
const value = myCache.get('key1');
cache-ts
is licensed under the MIT License. Feel free to use and contribute!
If you encounter any issues or have suggestions, please open an issue.
Happy caching! 🚀
FAQs
Simple and Efficient Cache Implementation for TypeScript
The npm package cache-ts receives a total of 1,024 weekly downloads. As such, cache-ts popularity was classified as popular.
We found that cache-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.