| | |
| | | /** @typedef {import("./Cache")} Cache */ |
| | | /** @typedef {import("./Cache").Etag} Etag */ |
| | | /** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */ |
| | | /** @typedef {typeof import("./util/Hash")} HashConstructor */ |
| | | /** @typedef {import("./util/Hash").HashFunction} HashFunction */ |
| | | |
| | | /** |
| | | * Defines the callback cache callback. |
| | | * @template T |
| | | * @callback CallbackCache |
| | | * @param {(Error | null)=} err |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the callback normal error cache callback. |
| | | * @template T |
| | | * @callback CallbackNormalErrorCache |
| | | * @param {(Error | null)=} err |
| | |
| | | |
| | | class MultiItemCache { |
| | | /** |
| | | * Creates an instance of MultiItemCache. |
| | | * @param {ItemCacheFacade[]} items item caches |
| | | */ |
| | | constructor(items) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns value. |
| | | * @template T |
| | | * @param {CallbackCache<T>} callback signals when the value is retrieved |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns promise with the data. |
| | | * @template T |
| | | * @returns {Promise<T>} promise with the data |
| | | */ |
| | | getPromise() { |
| | | /** |
| | | * Returns promise with the data. |
| | | * @param {number} i index |
| | | * @returns {Promise<T>} promise with the data |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided data. |
| | | * @template T |
| | | * @param {T} data the value to store |
| | | * @param {CallbackCache<void>} callback signals when the value is stored |
| | |
| | | } |
| | | |
| | | /** |
| | | * Stores the provided data. |
| | | * @template T |
| | | * @param {T} data the value to store |
| | | * @returns {Promise<void>} promise signals when the value is stored |
| | |
| | | |
| | | class ItemCacheFacade { |
| | | /** |
| | | * Creates an instance of ItemCacheFacade. |
| | | * @param {Cache} cache the root cache |
| | | * @param {string} name the child cache item name |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns value. |
| | | * @template T |
| | | * @param {CallbackCache<T>} callback signals when the value is retrieved |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns promise with the data. |
| | | * @template T |
| | | * @returns {Promise<T>} promise with the data |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided data. |
| | | * @template T |
| | | * @param {T} data the value to store |
| | | * @param {CallbackCache<void>} callback signals when the value is stored |
| | |
| | | } |
| | | |
| | | /** |
| | | * Stores the provided data. |
| | | * @template T |
| | | * @param {T} data the value to store |
| | | * @returns {Promise<void>} promise signals when the value is stored |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided computer. |
| | | * @template T |
| | | * @param {(callback: CallbackNormalErrorCache<T>) => void} computer function to compute the value if not cached |
| | | * @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns promise with the data. |
| | | * @template T |
| | | * @param {() => Promise<T> | T} computer function to compute the value if not cached |
| | | * @returns {Promise<T>} promise with the data |
| | |
| | | |
| | | class CacheFacade { |
| | | /** |
| | | * Creates an instance of CacheFacade. |
| | | * @param {Cache} cache the root cache |
| | | * @param {string} name the child cache name |
| | | * @param {(string | HashConstructor)=} hashFunction the hash function to use |
| | | * @param {HashFunction=} hashFunction the hash function to use |
| | | */ |
| | | constructor(cache, name, hashFunction) { |
| | | this._cache = cache; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns child cache. |
| | | * @param {string} name the child cache name# |
| | | * @returns {CacheFacade} child cache |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns item cache. |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | | * @returns {ItemCacheFacade} item cache |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets lazy hashed etag. |
| | | * @param {HashableObject} obj an hashable object |
| | | * @returns {Etag} an etag that is lazy hashed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Merges the provided values into a single result. |
| | | * @param {Etag} a an etag |
| | | * @param {Etag} b another etag |
| | | * @returns {Etag} an etag that represents both |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns value. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns promise with the data. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided identifier. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Stores the provided identifier. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided identifier. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns promise with the data. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |