Instance state type
Headers type
Params type
Instance state type
Headers type
Params type
Get active keys set (for SWR tracking).
Get the cache adapter (if configured).
Get the default stale time for SWR.
Get the default TTL.
Whether the policy is initialized and enabled.
Get revalidating keys set (for SWR tracking).
Clear all active keys.
Clear the rules cache.
Call this if you need to force re-computation of rules, though typically this is not needed.
ProtectedcomputeCompute rule configuration for a method+path combination.
This is the expensive O(n) operation that gets memoized. Finds matching rule and merges with policy defaults.
HTTP method (uppercase)
Request path
Computed rule or null if disabled
Get all active cache keys.
ProtectedgetGet the default HTTP methods for caching.
ProtectedgetGet the default serializer for caching.
Initialize the cache policy with configuration.
Optionalconfig: boolean | CacheConfig<S, H, P>Check if a key is currently being revalidated.
Mark a key as actively being fetched.
Mark a key as being revalidated in background.
ProtectedmergeResolve policy configuration for a specific request.
Uses memoization for rule matching (O(n) only once per method+path). Skip callbacks are always evaluated since they depend on request context.
HTTP method (uppercase)
Request path
Full request context for skip callback
OptionalskipCallback: (ctx: RequestKeyOptions<S, H, P>) => boolean | undefinedOptional skip callback from config
Resolved rule or null if disabled
Unmark a key as actively being fetched.
Unmark a key as being revalidated.
Cache policy for storing and retrieving response data.
Supports stale-while-revalidate (SWR) pattern where stale cached data is returned immediately while fresh data is fetched in the background.