class TimedCache {
  #cache;
  #ttlMs;
  #intervalHandle;
  constructor(ttlMs) {
    this.#cache = /* @__PURE__ */ new Map();
    this.#ttlMs = ttlMs;
    this.#intervalHandle = setInterval(() => {
      const now = Date.now();
      for (const [key, entry] of this.#cache.entries()) {
        if (entry.expiresAt < now) {
          this.#cache.delete(key);
        }
      }
    }, ttlMs * 2);
  }
  set(key, value) {
    const entry = { value, expiresAt: Date.now() + this.#ttlMs };
    this.#cache.set(key, entry);
  }
  get(key) {
    const entry = this.#cache.get(key);
    if (entry === void 0 || entry.expiresAt < Date.now()) {
      this.#cache.delete(key);
      return void 0;
    }
    return entry.value;
  }
  destroy() {
    clearInterval(this.#intervalHandle);
    this.#cache.clear();
  }
}
export {
  TimedCache
};
//# sourceMappingURL=cache.js.map
