UNPKG

701 BTypeScriptView Raw
1declare type cacheEvictionPolicy = "FIFO" | "LIFO" | "LRU" | "MRU";
2
3declare class Cache {
4 length: number;
5 constructor(options?: {
6 evictionPolicy?: cacheEvictionPolicy;
7 maxLength?: number;
8 ttl?: number;
9 interval?: number;
10 enableInterval?: boolean;
11 });
12 set: (key: any, value: any, options?: { ttl?: number }) => void;
13 startInterval: () => void;
14 clearInterval: () => void;
15 get: (
16 key: any,
17 callback?: (err: Error | undefined, value: any) => any
18 ) => any;
19 delete: (key: any) => void;
20 clear: () => void;
21 has: (key: any) => boolean;
22 forEach: (callback: (element: object, index?: number) => void) => void;
23 toArray: () => any[];
24}
25
26export default Cache;