LruTtlMap.d.ts 1.0 KB

1234567891011121314151617181920212223242526
  1. import { LruMap } from './LruMap';
  2. /**
  3. * An {@link LruMap} where each entry additionally carries an absolute expiry
  4. * deadline, in the same units as the `now` timestamps supplied to reads
  5. * (milliseconds since the Unix epoch, by default).
  6. */
  7. export declare class LruTtlMap<K, V> extends LruMap<K, V> {
  8. private readonly expiry;
  9. clear(): void;
  10. delete(key: K): boolean;
  11. /**
  12. * @param now Current time, defaults to `Date.now()`. Entries with a deadline
  13. * strictly below it are treated as missing and are removed.
  14. */
  15. has(key: K, now?: number): boolean;
  16. /**
  17. * @param now Current time, defaults to `Date.now()`. Entries with a deadline
  18. * strictly below it are treated as missing and are removed.
  19. */
  20. get(key: K, now?: number): V | undefined;
  21. /**
  22. * @param expiry Absolute deadline after which the entry expires, defaults to
  23. * `Infinity` (never expires). For a relative TTL use `Date.now() + ttl`.
  24. */
  25. set(key: K, value: V, expiry?: number): this;
  26. }