Skip to content

CacheBackend

import type { CacheBackend, CacheBackendOptions } from '@requence/cache'
interface CacheBackend {
get(key: string, args: string): Promise<any>
getTags(key: string, args: string): Promise<string[]>
set(key: string, args: string, collectionResult: BackendCollectionResult): Promise<void>
invalidateArgs(key: string, args: string): Promise<void>
invalidateKey(key: string): Promise<void>
invalidateTag(tag: string): Promise<void>
reset(): Promise<void>
}

Retrieve a cached value. Should throw if the key is not found.

Return the tags associated with a cached entry.

Store a result. The collectionResult is a Promise that resolves to the computed value, tags, and a shouldCache flag.

Remove a specific cached entry.

Remove all entries for a given function key.

Remove all entries associated with a tag.

Clear all data from the backend.

BackendModuleDescription
MemoryBackend@requence/cacheIn-memory Map-based storage with TTL and LRU eviction
RedisBackend@requence/cache/redisRedis-backed storage with Pub/Sub coordination
CombinedBackend(internal)Wraps multiple backends as a single read-through chain