import LRUCache from 'lru-cache'; /** * Simple LRU Cache that allows for keys of type Buffer * @hidden */ export default class Cache { _cache: LRUCache; constructor(opts: LRUCache.Options) { this._cache = new LRUCache(opts); } set(key: string | Buffer, value: V): void { if (key instanceof Buffer) { key = key.toString('hex'); } this._cache.set(key, value); } get(key: string | Buffer): V | undefined { if (key instanceof Buffer) { key = key.toString('hex'); } return this._cache.get(key); } del(key: string | Buffer): void { if (key instanceof Buffer) { key = key.toString('hex'); } this._cache.del(key); } }