Skip to content

v0.3.0

Latest

Choose a tag to compare

@yidinghan yidinghan released this 31 Oct 08:55

πŸŽ‰ 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 CacheMapClass and KeyMapClass options
  • 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