/** * @module Cache */ import { type ICacheAdapter } from "../../../../cache/contracts/_module.js"; import { type PluginFn } from "../../../../middleware/contracts/_module.js"; /** * Settings for the {@link withCacheJitter} plugin. * * IMPORT_PATH: `"@daiso-tech/core/cache/plugins"` * @group Plugins */ export type WithCacheJitterSettings = { /** * The jitter factor as a ratio of the original TTL. * For example, `0.2` means the TTL will be randomly adjusted by 20 %. * A value of `0` disables jitter entirely. * * @default 0.2 */ defaultJitter?: number; /** * @internal */ _mathRandom?: () => number; }; /** * Creates a plugin that adds random jitter to TTL values on cache `add` and * `put` operations. * * Applying jitter to TTLs helps prevent cache stampedes / thundering-herd * problems by staggering the expiration times of cache entries that were * originally created with the same TTL. * * @param settings - Configuration for the jitter behaviour. * @param settings.defaultJitter - The jitter factor as a ratio of the original * TTL (e.g., `0.2` means 20 %). * @default 0.2 * @returns A middleware plugin that wraps an `ICacheAdapter`. * * IMPORT_PATH: `"@daiso-tech/core/cache/plugins"` * @group Plugins */ export declare function withCacheJitter(settings?: WithCacheJitterSettings): PluginFn;