import { LRUCache } from 'lru-cache';
/**
 * A cache using local memory.
 */
export class MemoryCache {
    timeToLiveInSeconds;
    cache;
    /**
     * @param timeToLiveInSeconds time-to-live for every key-value pair set in the cache
     */
    constructor(timeToLiveInSeconds) {
        this.timeToLiveInSeconds = timeToLiveInSeconds;
        this.cache = new LRUCache({
            max: 100_000,
            ttl: timeToLiveInSeconds * 1000
        });
    }
    async set(key, value) {
        try {
            this.cache.set(key, value);
        }
        catch {
            // let the code continue as this is a non-fatal error
        }
    }
    async get(key) {
        return this.cache.get(key);
    }
}
//# sourceMappingURL=memory-cache.js.map