UNPKG

@httpc/kit

Version:

httpc toolbox for building function-based API with minimal code and end-to-end type safety

29 lines (28 loc) 604 B
import LRU from "lru-cache"; export class LruCache { constructor(options) { const { size = 100, ttl = 0 } = options; this.provider = new LRU({ max: size, ttl, }); } keys() { return this.provider.keys(); } has(key) { return this.provider.has(key); } get(key) { return this.provider.get(key); } set(key, value) { this.provider.set(key, value); } delete(key) { this.provider.delete(key); } clear() { this.provider.clear(); } }