import type { CacheBackend } from "../types.js"; import { type CodeCacheGateway, createTokenizingGateway, type TokenizingCacheGateway } from "../tokenizing-gateway.js"; export type { CodeCacheGateway, TokenizingCacheGateway }; export interface CacheBackendConfig { keyPrefix?: string; memoryMaxEntries?: number; preferredBackend?: "api" | "redis" | "disk" | "memory"; apiBaseUrl?: string; circuitBreakerName?: string; } export declare function isApiCacheAvailable(): boolean; export declare function isDiskCacheConfigured(): boolean; /** * Whether a local dev server must keep compiled code on disk. * * A local dev server has no hosted API cache and no Redis, so its code caches * live in memory and every restart recompiles the whole import tree. The disk * backend keeps that work under the project cache directory, so a restart * stays warm with no setup. * * This never changes a hosted or production runtime: the API and Redis * backends are resolved first, an explicit `VF_CACHE_BACKEND` always wins, and * anything other than a development environment keeps its current backend. */ export declare function isLocalDevDiskCacheEnabled(): boolean; /** * Whether this runtime has a cache that outlives the process. * * Servers use this to decide whether to run the distributed-cache * initializers at startup. Without initialization the SSR module cache stays * disabled and the loader skips both reads and writes, so a gate that only * checks the explicit disk configuration leaves the local dev cache inert. */ export declare function isPersistentLocalCacheEnabled(): boolean; /** * Backend preference for caches that hold compiled code. * * Returns `undefined` outside local dev so the normal API, Redis, disk, memory * resolution order applies unchanged. */ export declare function localDevCodeCacheBackend(): CacheBackendConfig["preferredBackend"]; export declare function createCacheBackend(config?: CacheBackendConfig): Promise; export declare function isDistributedBackend(backend: CacheBackend): boolean; export declare function createDistributedCacheAccessor(factory: () => Promise, name: string, getScopeKey?: () => string): () => Promise; export declare const CacheBackends: { transform: () => Promise; file: () => Promise; module: () => Promise; render: () => Promise; userKv: () => Promise; httpModule: () => Promise; ssrModule: () => Promise; projectCSS: () => Promise; /** * Create a TokenizingCacheGateway for code storage. * This is the ONLY authorized way to store transformed code in distributed cache. * * The gateway automatically handles: * - Tokenization on write (replaces absolute paths with __VF_CACHE_DIR__) * - Detokenization on read (replaces tokens with local paths) * - Validation to ensure code is portable before storage * * @param name - Name for logging (e.g., "TRANSFORM-CACHE", "SSR-MODULE") * @param config - Cache backend configuration * @returns A gateway that enforces tokenization for code storage */ codeStore: (name: string, config?: CacheBackendConfig) => Promise; }; /** * Create a distributed cache accessor that returns a TokenizingCacheGateway. * This wraps createDistributedCacheAccessor with automatic gateway creation. */ export declare function createDistributedCodeCacheAccessor(factory: () => Promise, name: string, getScopeKey?: () => string): () => Promise; export { createTokenizingGateway }; //# sourceMappingURL=factory.d.ts.map