ltcache
Version:
A lightweight, in-memory caching library - like Redis but much simpler. Features TTL support, concurrent request handling, and comprehensive statistics. Perfect for Node.js applications that need fast caching without the complexity of Redis.
14 lines (13 loc) • 427 B
TypeScript
export type Cache = {
get: <T>(key: string, fn?: () => Promise<T>, lifetimeInSeconds?: number) => Promise<T>;
set: <T>(key: string, value: T, lifetimeInSeconds?: number) => void;
remove: (key: string | RegExp) => void;
reset: () => void;
report: () => Report;
};
export type Report = {
numItems: number;
hitRate: number;
sizeKb: number;
};
export declare function cache(debug?: boolean): Cache;