import QuickLRU from 'quick-lru';
/**
 * Time Aware Least Recent Used Cache
 *
 * @see https://arxiv.org/pdf/1801.00390
 */
export class TLRU {
    lru;
    constructor(maxSize) {
        this.lru = new QuickLRU({ maxSize });
    }
    get(key) {
        return this.lru.get(key);
    }
    set(key, value, ttlMs) {
        this.lru.set(key, value, {
            maxAge: Date.now() + ttlMs
        });
    }
    has(key) {
        const value = this.get(key);
        if (value != null) {
            return true;
        }
        return false;
    }
    remove(key) {
        this.lru.delete(key);
    }
    clear() {
        this.lru.clear();
    }
}
//# sourceMappingURL=tlru.js.map