@ocyrusjs/lru
v1.0.0
Published
Blazing fast, zero-dependency LRU cache using Map insertion order.
Maintainers
Readme
@ocyrusjs/lru 🌑
Blazing fast, zero-dependency LRU cache using Map insertion order.
Part of the Ocyrus suite.
✨ Features
- Map-Based: Leverages the native
Map's insertion order for high-performance O(1) eviction. - Auto-Eviction: Automatically removes the Least Recently Used item when the capacity is reached.
- Refresh on Access: Updates item priority on
get()andset(). - Tiny: Zero dependencies and minimal code size.
🚀 Performance
get(hit): ~1.0M ops/secset(with eviction): ~1.8M ops/sec
📦 Installation
npm install @ocyrusjs/lru🛠️ Usage
import { LRU } from '@ocyrusjs/lru';
const cache = new LRU<string, number>(100);
cache.set('key', 1);
cache.get('key'); // 1
// When 101st item is added, the oldest item is evicted.License
MIT © Nishith Patel
