import type { types } from '@balena/pinejs'; import type { Options as MemoizeeOptions } from 'memoizee'; import type { Defined } from './index.js'; import { createMultiLevelStore } from './index.js'; type MultiCacheMemoizeeOpts any> = { cacheKey?: string; undefinedAs?: Defined; promise: true; primitive: true; /** In milliseconds like memoizee */ maxAge: number; /** This only applies to the local in-memory cache, the shared cache is unbounded */ max?: MemoizeeOptions['max']; } & Pick, 'preFetch' | 'normalizer'>; declare const memoizeeExtraOptionsKeys: readonly ["max", "maxAge", "preFetch"]; type AnyFunction = (...args: any[]) => any; type SharedMultiCacheMemoizeeExtraOpts = Exclude>, 'max'>; type MultiCacheMemoizeeExtraOpts = Pick, (typeof memoizeeExtraOptionsKeys)[number]>; export interface MemoizedFn Promise> { (...args: Parameters): Promise>; delete: (...args: Parameters) => Promise; } type ExtraCacheOptsByType = { local?: Partial> | false; global?: SharedMultiCacheMemoizeeExtraOpts; } & Pick[1], 'useVersion'>; /** * A multi layer cache compatible with a subset of memoizee options * Note: `undefined`/`null` can only be locally cached so avoid if possible * * @example * multiCacheMemoizee('test', { * maxAge: 24 * HOURS, * }, { * local: false, // Disable the local cache * }); * * @example * multiCacheMemoizee('test', { * maxAge: 1 * HOURS, * }, { * global: { * maxAge: 24 * HOURS, // override the shared cache (redis) ttl * } * }); */ export declare function multiCacheMemoizee Promise>(fn: T, opts: types.RequiredField, 'undefinedAs'>, extraCacheOpts: ExtraCacheOptsByType): MemoizedFn; export declare function multiCacheMemoizee Promise>(fn: T, opts: MultiCacheMemoizeeOpts, extraCacheOpts: ExtraCacheOptsByType): MemoizedFn; export {};