interface CacheAdapter

Cache adapter interface for cache-agnostic operations.

Implement this interface to create drivers for specific cache backends. The Cache class wraps adapters with Task semantics.

Methods

get(key: string): Promise<unknown | null>

Retrieve a value by key. Returns null if the key does not exist or has expired.

set(
key: string,
value: unknown,
options?: SetOptions,
): Promise<void>

Store a value with an optional TTL in milliseconds.

delete(key: string): Promise<void>

Remove a key. No error if the key does not exist.

has(key: string): Promise<boolean>

Check whether a key exists and has not expired.

close(): Promise<void>

Release any resources held by this adapter instance.

Usage

import { type CacheAdapter } from ".";