Repository navigation
π Custom Map Class Support
Version 0.3.0 adds support for custom Map implementations, enabling advanced caching strategies like LRU eviction, size limits, and
custom monitoring.
β¨ New Features
- Custom Map Classes: Pass your own Map implementation via
CacheMapClassandKeyMapClassoptions - Type Safety: Automatic validation ensures classes extend native Map
- Backward Compatible: Defaults to native Map when not specified
π Usage Example
class LRUMap extends Map {
constructor(maxSize = 1000) {
super();
this.maxSize = maxSize;
}
set(key, value) {
if (this.size >= this.maxSize) {
const firstKey = this.keys().next().value;
this.delete(firstKey);
}
return super.set(key, value);
}
}
const cache = new SimpleClientSideCache({
CacheMapClass: LRUMap,
KeyMapClass: LRUMap
});π¦ What's Included
- 8 new comprehensive tests
- Example implementations: LRUMap, LimitedMap, MonitoredMap
- Updated documentation with usage guide
π Links
Full Changelog: v0.2.0...v0.3.0