ghost-cache
Version:
A lightweight auto-caching wrapper for fetch() and Axios with multi-storage support (localStorage, sessionStorage, IndexedDB, Redis)
33 lines • 1.03 kB
TypeScript
import { AxiosInstance } from "axios";
import { IStorageAdapter } from "./storage/IStorageAdapter.js";
export interface GhostCacheOptions {
ttl?: number;
persistent?: boolean;
maxEntries?: number;
storage?: "localStorage" | "sessionStorage" | IStorageAdapter;
}
/**
* Enable GhostCache: intercept fetch and (optionally) Axios requests.
*/
export declare function enableGhostCache(options?: GhostCacheOptions): void;
/**
* Manually set a cache entry.
*/
export declare function setCache(key: string, value: any): Promise<void>;
/**
* Retrieve a cache entry.
*/
export declare function getCache<T = any>(key: string): Promise<T | null>;
/**
* Clear all cache entries.
*/
export declare function clearGhostCache(): void;
/**
* Disable GhostCache and restore the original fetch.
*/
export declare function disableGhostCache(): void;
/**
* Register an Axios instance to intercept its requests.
*/
export declare function registerAxios(instance: AxiosInstance): void;
//# sourceMappingURL=ghostCache.d.ts.map