import { CacheValue, IncrementalCache, WithLastModified } from "@opennextjs/aws/types/overrides.js"; import { IncrementalCacheEntry } from "../internal.js"; type Options = { /** * The mode to use for the regional cache. * * - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved. * - `long-lived`: Re-use a fetch cache entry until it is revalidated (per-region), * or an ISR/SSG entry for up to 30 minutes. */ mode: "short-lived" | "long-lived"; /** * The default TTL of long-lived cache entries. * When no revalidate is provided, the default age will be used. * * @default `THIRTY_MINUTES_IN_SECONDS` */ defaultLongLivedTtlSec?: number; /** * Whether the regional cache entry should be updated in the background or not when it experiences * a cache hit. * * @default `false` for the `short-lived` mode, and `true` for the `long-lived` mode. */ shouldLazilyUpdateOnCacheHit?: boolean; }; interface PutToCacheInput { key: string; isFetch: boolean | undefined; entry: IncrementalCacheEntry; } /** * Wrapper adding a regional cache on an `IncrementalCache` implementation */ declare class RegionalCache implements IncrementalCache { private store; private opts; name: string; protected localCache: Cache | undefined; constructor(store: IncrementalCache, opts: Options); get(key: string, isFetch?: IsFetch): Promise> | null>; set(key: string, value: CacheValue, isFetch?: IsFetch): Promise; delete(key: string): Promise; protected getCacheInstance(): Promise; protected getCacheUrlKey(key: string, isFetch?: boolean): string; protected putToCache({ key, isFetch, entry }: PutToCacheInput): Promise; } /** * A regional cache will wrap an incremental cache and provide faster cache lookups for an entry * when making requests within the region. * * The regional cache uses the Cache API. * * **WARNING:** * If an entry is revalidated on demand in one region (using either `revalidateTag`, `revalidatePath` or `res.revalidate` ), it will trigger an additional revalidation if * a request is made to another region that has an entry stored in its regional cache. * * @param cache Incremental cache instance. * @param opts.mode The mode to use for the regional cache. * - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved. * - `long-lived`: Re-use a fetch cache entry until it is revalidated (per-region), * or an ISR/SSG entry for up to 30 minutes. * @param opts.shouldLazilyUpdateOnCacheHit Whether the regional cache entry should be updated in * the background or not when it experiences a cache hit. * @param opts.defaultLongLivedTtlSec The default age to use for long-lived cache entries. * When no revalidate is provided, the default age will be used. * @default `THIRTY_MINUTES_IN_SECONDS` * * @default `false` for the `short-lived` mode, and `true` for the `long-lived` mode. */ export declare function withRegionalCache(cache: IncrementalCache, opts: Options): RegionalCache; export {};