UNPKG

@thermopylae/lib.cache

Version:
39 lines (38 loc) 790 B
class EsMapCacheBackend { store; constructor() { this.store = new Map(); } get(key) { return this.store.get(key); } has(key) { return this.store.has(key); } set(key, value) { const entry = { key, value }; this.store.set(key, entry); return entry; } del(entry) { entry.value = undefined; this.store.delete(entry.key); entry.key = undefined; } clear() { return this.store.clear(); } get size() { return this.store.size; } [Symbol.iterator]() { return this.store[Symbol.iterator](); } keys() { return this.store.keys(); } values() { return this.store.values(); } } export { EsMapCacheBackend };