import { s as SequentialInterval } from "./index-C9PaKl0y.mjs"; import { Logger } from "@wcaservices/logger"; //#region src/cache/CachedItem.d.ts declare class CachedItem { protected readonly config: CachedItemConfig; protected readonly store: CacheAdapter; protected static INFINITE_TTL_TIMESTAMP: number; protected static createExpiryDate(ttlSeconds: number): Date; expiresAt: Date; readonly logger?: Logger; constructor(config: CachedItemConfig, store: CacheAdapter); get value(): T; isExpired(): boolean; delete(): void; get key(): string; } interface CachedItemConfig { key: string; value: TValue; ttlSeconds: number; } //#endregion //#region src/cache/CacheNamespace.d.ts declare class CacheNamespace implements Partial { protected readonly namespace: string; protected readonly cache: CacheAdapter; constructor(namespace: string, cache: CacheAdapter); /** * Format the provided cache key to include this namespace's key prefix. * @param key */ protected formatKey(key: string): string; /** * Retrieve an item from the cache by its key. * @param key */ get(key: string): CachedItem | null; /** * Remove the provided key from the cache (if it exists) * @param key */ delete(key: string): void; /** * Write (or overwrite) the provided value to the cache. * @param config */ set(config: CachedItemConfig): TValue; /** * Cache the result of the provided callback. * The callback will be executed only when the provided cache key is unset or has expired. * @param item */ remember(item: { key: string; ttlSeconds: number; handler: () => TValue; }): TValue; /** * Clear out expired entries from the internal cache store. */ prune(): void; } //#endregion //#region src/cache/CacheAdapter.d.ts declare class CacheAdapter { readonly logger?: Logger; protected readonly _store: CacheStore; protected readonly pruneInterval: SequentialInterval; constructor(config: CacheAdapterConfig); /** * Proxy of the current cache but where all keys are namespaced to the provided string to avoid naming conflicts. * @param namespace Identifier to use as the prefix for cache keys. */ createNamespace(namespace: string): CacheNamespace; /** * Retrieve an item from the cache by its key. * @param key */ get(key: string): CachedItem | null; /** * Remove the provided key from the cache (if it exists) * @param key */ delete(key: string): void; /** * Write (or overwrite) the provided value to the cache. * @param config */ set(config: CachedItemConfig): TValue; /** * Cache the result of the provided callback. * The callback will be executed only when the provided cache key is unset or has expired. * @param item */ remember(item: { key: string; ttlSeconds: number; handler: () => TValue; }): TValue; /** * Clear out expired entries from the internal cache store. */ prune(): void; /** * Remove all items from the local cache store. */ deleteAll(): void; } interface CacheAdapterConfig { store: CacheStore; logger?: Logger; /** * How often should the cache be checked for expired entries. */ pruneIntervalMs?: number; } interface CacheStore { get(key: string): CachedItem | null | undefined; set(key: string, value: CachedItem): any; delete(key: string): void; entries(): MapIterator<[string, CachedItem]>; has(key: string): boolean; clear(): void; size: number; } //#endregion //#region src/cache/MemoryCache.d.ts declare const MemoryCache: CacheAdapter; //#endregion export { CacheAdapter as n, CachedItem as r, MemoryCache as t }; //# sourceMappingURL=index-BO1gH0MD.d.mts.map