API Reference
Types and options for createCache and cache helpers.
CreateCacheOptions
| Option | Type | Description |
|---|---|---|
env? | | Environment name override. When omitted, falls back to Values |
inMemoryDuringBuild? | | When true |
redis? | | Legacy Upstash credentials or client. Mutually exclusive with |
store? | | Explicit store implementation (preferred). |
logger? | | Application logger. Defaults to a silent no-op logger. |
ttl? | | Override default TTL seconds per duration name ( |
keyGenerator? | | Default key generator for all |
cacheFailures? | | Default for |
staleWhileRevalidate? | | Default stale-while-revalidate window in seconds for |
CacheClient
| Prop | Type | Description |
|---|---|---|
clearAllCache | | Clears all cached entries. Works with the in-memory dev store or stores that implement |
getCache | | Returns the lazily initialized CacheStore backing this client. |
getCacheStats | | Returns cache statistics when the active store supports synchronous stats. Available for the in-memory store; returns |
getTTL | | Resolves a TTL duration name to seconds for the active environment. Respects |
inMemoryCache | | Returns the underlying InMemoryCache when the active store is in-memory. Returns |
invalidateCache | | Deletes cache keys matching a glob pattern under an optional prefix. |
invalidateCacheKey | | Deletes a single cache key by exact match. |
reset | | Tears down the active store instance and resets lazy initialization. Useful in tests to isolate cache state between cases. |
withCache | | Wraps an async function with read-through caching. Caches successful return values and |
CacheOptions
| Option | Type | Description |
|---|---|---|
cacheFailures? | | Opt-in negative caching for failed |
keyGenerator? | | Builds the cache key suffix from function arguments. The |
prefix? | | Key namespace prepended to every cache key. "cache" |
staleWhileRevalidate? | | Stale-while-revalidate window in seconds. Overrides |
ttl? | | TTL duration bucket for cached successes. Resolved to seconds via CacheClient.getTTL for the active environment. "long" |
CacheKeyOptions
| Option | Type | Description |
|---|---|---|
includePagination? | | When true |
maxLength? | | Max key length before replacing the param segment with an MD5 hash. 150 |
separator? | | Separator between key segments. ":" |