1 |
|
2 |
|
3 |
|
4 | export interface ICache {
|
5 |
|
6 | setItem(key: string, value: any, options?: CacheItemOptions): void;
|
7 |
|
8 | getItem(key: string, options?: CacheItemOptions): any;
|
9 |
|
10 | removeItem(key: string): void;
|
11 |
|
12 | clear(): void;
|
13 |
|
14 | getAllKeys(): string[] | Promise<string[]>;
|
15 |
|
16 | getCacheCurSize(): number | Promise<number>;
|
17 |
|
18 | createInstance(config: CacheConfig): ICache;
|
19 |
|
20 | configure(config: CacheConfig): CacheConfig;
|
21 | }
|
22 |
|
23 |
|
24 |
|
25 | export interface CacheConfig {
|
26 |
|
27 | keyPrefix?: string;
|
28 |
|
29 | capacityInBytes?: number;
|
30 |
|
31 | itemMaxSize?: number;
|
32 |
|
33 | defaultTTL?: number;
|
34 |
|
35 | warningThreshold?: number;
|
36 |
|
37 | defaultPriority?: number;
|
38 | storage?: Storage;
|
39 | Cache?: Cache;
|
40 | }
|
41 | export interface CacheItem {
|
42 | key: string;
|
43 | data: any;
|
44 | timestamp: number;
|
45 | visitedTime: number;
|
46 | priority: number;
|
47 | expires: number;
|
48 | type: string;
|
49 | byteSize: number;
|
50 | }
|
51 | export interface CacheItemOptions {
|
52 | priority?: number;
|
53 | expires?: number;
|
54 | callback?: Function;
|
55 | }
|