/** Where cached values live. `get` and `set` may be synchronous or asynchronous. */ export interface CacheAdapter { /** Returns the cached value, or `undefined` for a miss or an expired entry. */ get(key: string): Promise | T | undefined; /** Stores a value, for `ttlSeconds` when given. */ set(key: string, value: T, ttlSeconds?: number): Promise | void; /** Removes a value. Returns true when one was removed. */ delete?(key: string): Promise | boolean; /** Removes every value. */ clear?(): Promise | void; } /** Cache values in process memory. Expired entries are dropped when read. */ export declare class MemoryCacheAdapter implements CacheAdapter { private entries; /** Returns the cached value, or `undefined` for a miss or an expired entry. */ get(key: string): T | undefined; /** Stores a value. Defaults to 5 minutes. */ set(key: string, value: T, ttlSeconds?: number): void; /** Removes a value. */ delete(key: string): boolean; /** Removes every value. */ clear(): void; } /** The Redis commands the cache adapter needs, in `ioredis` argument order. */ export interface RedisLikeClient { /** Reads a key. */ get(key: string): Promise | string | null; /** Writes a key, with `EX` and a TTL in seconds. */ set(key: string, value: string, mode?: string, ttlSeconds?: number): Promise | unknown; /** Deletes a key. */ del?(key: string): Promise | number; } /** Cache values in Redis, shared across processes. Values are stored as JSON under a key prefix. */ export declare class RedisCacheAdapter implements CacheAdapter { private client; private prefix; constructor(client: RedisLikeClient, prefix?: string); /** Returns the cached value, or `undefined` for a miss. */ get(key: string): Promise; /** Stores a value. Defaults to 5 minutes. */ set(key: string, value: T, ttlSeconds?: number): Promise; /** Removes a value. Returns false when the client has no `del`. */ delete(key: string): Promise; } /** * The part of a SQLite database handle the cache adapter needs, as `better-sqlite3` provides it. */ export interface SQLiteLikeDatabase { /** Prepares a statement. */ prepare(sql: string): { get?: (...args: unknown[]) => unknown; run?: (...args: unknown[]) => unknown; }; /** Runs SQL without results, used to create the table. */ exec?(sql: string): unknown; } /** Cache values in a SQLite table, for a single-machine cache that survives restarts. */ export declare class SQLiteCacheAdapter implements CacheAdapter { private db; private table; constructor(db: SQLiteLikeDatabase, table?: string); /** Returns the cached value, or `undefined` for a miss or an expired entry. */ get(key: string): T | undefined; /** Stores a value. Defaults to 5 minutes. */ set(key: string, value: T, ttlSeconds?: number): void; /** * Removes a value. Always returns true, since SQLite does not report whether the row existed * here. */ delete(key: string): boolean; /** Removes every value. */ clear(): void; }