@intlayer/config
Version:
Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.
50 lines (49 loc) • 2.35 kB
TypeScript
import { IntlayerConfig } from "@intlayer/types";
//#region src/utils/cache.d.ts
/** Public stringify kept for convenience / debugging (now faster & broader). */
declare const stableStringify: (value: unknown, _stack?: WeakSet<object>) => string;
/** ------------------------- In-memory cache ------------------------- **/
type CacheKey = unknown;
declare const getCache: <T>(...key: CacheKey[]) => T | undefined;
type CacheSetArgs<T> = [...keys: CacheKey[], value: T];
declare const setCache: <T>(...args: CacheSetArgs<T>) => void;
declare const clearCache: (idOrKey: string) => void;
declare const clearAllCache: () => void;
declare const cache: {
get: <T>(...key: CacheKey[]) => T | undefined;
set: <T>(...args: CacheSetArgs<T>) => void;
clear: (idOrKey: string) => void;
};
/** ------------------------- Persistence layer ------------------------- **/
type LocalCacheOptions = {
/** Preferred new option name */
persistent?: boolean;
/** Time-to-live in ms; if expired, disk entry is ignored. */
ttlMs?: number;
/** Max age in ms based on stored creation timestamp; invalidates on exceed. */
maxTimeMs?: number;
/** Optional namespace to separate different logical caches. */
namespace?: string;
/** Gzip values on disk (on by default for blobs > 1KB). */
compress?: boolean;
};
/** ------------------------- Local cache facade ------------------------- **/
declare const localCache: (intlayerConfig: IntlayerConfig, keys: CacheKey[], options?: LocalCacheOptions) => {
/** In-memory first, then disk (if enabled), otherwise undefined. */
get: <T>() => Promise<T | undefined>;
/** Sets in-memory (always) and persists to disk if enabled. */
set: (value: unknown) => Promise<void>;
/** Clears only this entry from memory and disk. */
clear: () => Promise<void>;
/** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */
clearAll: () => Promise<void>;
/** Expose the computed id (useful if you want to key other structures). */
isValid: () => Promise<boolean>;
/** Expose the computed id (useful if you want to key other structures). */
id: string;
/** Expose the absolute file path for debugging. */
filePath: string;
};
//#endregion
export { cache, clearAllCache, clearCache, getCache, localCache, setCache, stableStringify };
//# sourceMappingURL=cache.d.ts.map