index.d.ts 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. interface LRFUExpirerOptions {
  2. lruSize?: number;
  3. cleanupInterval?: number;
  4. }
  5. export class LRFUExpirer {
  6. constructor(options?: LRFUExpirerOptions);
  7. }
  8. interface WeakLRUCacheOptions {
  9. cacheSize?: number;
  10. expirer?: LRFUExpirer | false;
  11. deferRegister?: boolean;
  12. }
  13. export class CacheEntry<V> {
  14. value?: V
  15. deref?(): V
  16. }
  17. export class WeakLRUCache<K, V> extends Map<K, CacheEntry<V>> {
  18. constructor(options?: WeakLRUCacheOptions);
  19. /**
  20. * Get a value from the cache, if it is still in memory. If the value is no longer cached, will return undefined.
  21. * @param key The key to use to retrieve the value
  22. */
  23. getValue(key: K): V | undefined;
  24. /**
  25. * Put a key-value into the cache
  26. * @param key The key to use to insert the entry
  27. * @param value The value to insert into the cache
  28. * @param expirationPriority A priority for expiration, a higher value will expire sooner
  29. */
  30. setValue(key: K, value: V, expirationPriority?: number): void;
  31. }