cache-common.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Cache as Cache_2 } from '@algolia/cache-common';
  2. export declare type Cache = {
  3. /**
  4. * Gets the value of the given `key`.
  5. */
  6. readonly get: <TValue>(key: object | string, defaultValue: () => Readonly<Promise<TValue>>, events?: CacheEvents<TValue>) => Readonly<Promise<TValue>>;
  7. /**
  8. * Sets the given value with the given `key`.
  9. */
  10. readonly set: <TValue>(key: object | string, value: TValue) => Readonly<Promise<TValue>>;
  11. /**
  12. * Deletes the given `key`.
  13. */
  14. readonly delete: (key: object | string) => Readonly<Promise<void>>;
  15. /**
  16. * Clears the cache.
  17. */
  18. readonly clear: () => Readonly<Promise<void>>;
  19. };
  20. export declare type CacheEvents<TValue> = {
  21. /**
  22. * The callback when the given `key` is missing from the cache.
  23. */
  24. readonly miss: (value: TValue) => Readonly<Promise<any>>;
  25. };
  26. export declare function createFallbackableCache(options: FallbackableCacheOptions): Cache;
  27. export declare function createNullCache(): Cache;
  28. export declare type FallbackableCacheOptions = {
  29. /**
  30. * List of caches order by priority.
  31. */
  32. readonly caches: readonly Cache_2[];
  33. };
  34. export { }