@chrono-cache/next
Version:
A custom cache handler for Next.js, designed to address a common challenge: the need for large and costly distributed cache solutions (e.g., Redis) in horizontally scaled applications hosted outside of Vercel
29 lines (25 loc) • 1.12 kB
TypeScript
import { CacheHandler, CacheHandlerContext, CacheHandlerValue } from 'next/dist/server/lib/incremental-cache';
import { IncrementalCacheKind, IncrementalCacheValue } from 'next/dist/server/response-cache/types';
import { Revalidate } from 'next/dist/server/lib/revalidate';
interface FileCacheValueContext {
kind: IncrementalCacheKind;
revalidate?: Revalidate;
fetchUrl?: string;
fetchIdx?: number;
tags?: string[];
softTags?: string[];
isRoutePPREnabled?: boolean;
isFallback: boolean | undefined;
}
declare class CustomCacheHandler implements CacheHandler {
private flushToDisk;
private memoryCache;
private fileCache?;
constructor(options: CacheHandlerContext);
revalidateTag(args: string[]): Promise<void>;
get(key: string, ctx: FileCacheValueContext): Promise<CacheHandlerValue | null>;
set(key: string, data: IncrementalCacheValue | null, ctx: FileCacheValueContext): Promise<void>;
resetRequestCache(): void;
static normalizeTags(args: string | string[]): string[];
}
export { CustomCacheHandler as CacheHandler, CustomCacheHandler as default };