/** * CacheScope - Runtime cache scope for iterator-based caching * * Each cache() boundary in the route tree creates a new CacheScope. * The scope owns: config, serialization, and storage operations. */ import type { PartialCacheOptions } from "../types.js"; import type { ResolvedSegment } from "../types.js"; import type { SerializedSegmentData } from "./types.js"; /** * Serialize segments for storage. * Each segment's component, layout, loading, and loaderData are RSC-serialized. * Metadata is preserved as-is. */ export declare function serializeSegments(segments: ResolvedSegment[]): Promise; /** * Deserialize segments from storage. * Reconstructs ResolvedSegment objects from RSC-serialized data. */ export declare function deserializeSegments(data: SerializedSegmentData[]): Promise; /** * CacheScope represents a cache boundary in the route tree. * * When withCache encounters an entry with cache config, it creates * a new CacheScope. The scope owns serialization, storage, and TTL. * * Store resolution priority: * 1. Explicit store in cache() options * 2. App-level store from handler config * * TTL resolution priority: * 1. Explicit value in cache() options * 2. Explicit store's defaults (if store specified) * 3. App-level store's defaults * 4. Hardcoded fallback (60 seconds) */ export declare class CacheScope { readonly config: PartialCacheOptions | false; readonly parent: CacheScope | null; /** Explicit store from cache() options, if specified */ private readonly explicitStore; constructor(config: PartialCacheOptions | false, parent?: CacheScope | null); /** * Whether caching is enabled for this scope */ get enabled(): boolean; /** * Get effective TTL from config or store defaults */ get ttl(): number; /** * Get SWR window from config or store defaults */ get swr(): number | undefined; /** * Get the cache store - resolution priority: * 1. Explicit store from cache() options * 2. App-level store from request context */ private getStore; /** * Resolve the cache key using custom key functions or default generation. * * Resolution priority: * 1. Route-level `key` function (full override) * 2. Store-level `keyGenerator` (modifies default key) * 3. Default key generation (prefix:pathname:params) * * @internal */ private resolveKey; /** * Lookup cached segments for a route (single cache entry per request). * Returns { segments, shouldRevalidate } or null if cache miss. * * @param pathname - URL pathname for cache key generation * @param params - Route params for cache key generation * @param isIntercept - Whether this is an intercept navigation (uses different cache key) */ lookupRoute(pathname: string, params: Record, isIntercept?: boolean): Promise<{ segments: ResolvedSegment[]; shouldRevalidate: boolean; } | null>; /** * Cache all segments for a route (non-blocking via waitUntil) * Single cache entry per route request. * Loaders are excluded - they're always fresh unless they have their own cache() config. * * @param pathname - URL pathname for cache key generation * @param params - Route params for cache key generation * @param segments - All resolved segments to cache * @param isIntercept - Whether this is an intercept navigation (uses different cache key) */ cacheRoute(pathname: string, params: Record, segments: ResolvedSegment[], isIntercept?: boolean): Promise; } /** * Create a cache scope from entry's cache config */ export declare function createCacheScope(config: { options: PartialCacheOptions | false; } | undefined, parent?: CacheScope | null): CacheScope | null; //# sourceMappingURL=cache-scope.d.ts.map