import { BasicCache } from "./engines"; import { CacheOptions, CacheOptionsParam, InlineCacheContext } from "./types"; export declare class CacheHandler { readonly engine: BasicCache; options: CacheOptions; constructor(engine: BasicCache, options?: CacheOptionsParam); clone(options?: CacheOptionsParam): CacheHandler; setOptions(options: CacheOptionsParam): void; /** * Convert the current key to an engine compatible key */ createKey(key: any): string; private _setRefreshKey; /** * Returns `true` if `key` is cached. Note that with `refreshInterval` enabled, * this function can return `true`, and a call to `get` will return an empty * result. */ exists(key: any): Promise; /** * Returns the cached value or, if not found, `undefined`. * * The `key` parameter can be any value. When this is not a string or it's too long, * the value will be hashed. * * If `updateRefreshInterval` is `true` (default), the refresh interval will be updated. * This will prevent concurrent refreshing of the cache. * If it's `false`, requests to `get` will always return `undefined` until the cache is * updated or `get` is called with `updateRefreshInterval` set to `true`. */ get(key: any, updateRefreshInterval?: boolean): Promise; private _get; set(key: any, value: any, ttl?: CacheOptions["ttl"]): Promise; private _set; /** * Force a refresh on the next `get` call. */ forceRefresh(key: any): Promise; delete(key: any): Promise; deleteAll(): Promise; /** * This function is used for the `call` and `inline` functions. * It will set an error value depending on `options.errorTtl` and * other settings. */ setError(key: any, value: any, errorTtl?: CacheOptions["errorTtl"]): Promise; private lockRequest; private handleCallError; /** * Function which will cache an async function call. * Depending on the options, it also will cache exceptions. */ call(key: any, fn: () => Promise): Promise; /** * This function will throw a `CacheFoundError` exception in case * of a cache hit. This exception will be caught by the response * handler of an addon action handler. * * It is basically a shortcut for things like * ``` * const value = await cache.get('key'); * if (value !== undefined) return value; * ``` */ inline(key: any): Promise; /** * Wait for a key to exists. */ waitKey(key: any, timeout?: number, del?: boolean, sleep?: number): Promise; }