
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
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,668 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.