@febin52/cache-lru-ts
v1.0.2
Published
High-performance TypeScript LRU (Least Recently Used) cache with TTL & zero dependencies.
Maintainers
Readme
⚡ @febin52/cache-lru-ts
High-performance TypeScript LRU (Least Recently Used) cache with TTL expiration & zero dependencies.
Fast in-memory LRU cache storing key-value pairs with automatic eviction of least recently used items when maximum size capacity is reached.
🚀 Features
- ⚡ O(1) Access: Ultra-fast Map-based LRU eviction strategy.
- ⏳ TTL Support: Time-To-Live expiration per cache instance or per item.
- 🛡️ Type-Safe: Full TypeScript generics support (
LRUCache<Key, Value>).
📦 Installation
npm install @febin52/cache-lru-ts💡 Usage
import { LRUCache } from '@febin52/cache-lru-ts';
// Max capacity of 500 items, 60s default TTL
const cache = new LRUCache<string, { name: string }>({ max: 500, ttl: 60000 });
cache.set('user:100', { name: 'Alice' });
cache.get('user:100'); // { name: 'Alice' }
cache.has('user:100'); // true
cache.size; // 1
cache.clear();🔗 Links
- NPM Package: https://www.npmjs.com/package/@febin52/cache-lru-ts
- GitHub Repository: https://github.com/febin52/cache-lru-ts
- Issue Tracker: https://github.com/febin52/cache-lru-ts/issues
📄 License
MIT © Febin Francis
