-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtoad-cache.d.cts
138 lines (127 loc) · 3.41 KB
/
toad-cache.d.cts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
type CacheConstructor<T> = new (max?: number, ttlInMsecs?: number, cacheId?: string, cacheStatistics?: HitStatisticsRecord) => T
type CacheEntry<T> = {
expiry: number
key: any
prev: CacheEntry<T> | null
next: CacheEntry<T> | null
value: T
}
interface ToadCache<T> {
first: any;
last: any;
max: number;
ttl: number;
size: number;
clear(): void;
delete(key: any): void;
deleteMany(keys: any[]): void;
evict(): void;
expiresAt(key: any): any;
keys(): any;
get(key: any): T | undefined;
getMany(keys: any[]): (T | undefined)[];
set(key: any, value: T): void;
}
declare class FifoMap<T> implements ToadCache<T>{
constructor(max?: number, ttlInMsecs?: number);
first: any;
items: Map<any, T>;
last: any;
max: number;
ttl: number;
size: number;
clear(): void;
delete(key: any): void;
deleteMany(keys: any[]): void;
evict(): void;
expiresAt(key: any): any;
get(key: any): T | undefined;
getMany(keys: any[]): (T | undefined)[];
keys(): IterableIterator<any>;
set(key: any, value: T): void;
}
declare class FifoObject<T> implements ToadCache<T> {
constructor(max?: number, ttlInMsecs?: number);
first: any;
items: Record<any, CacheEntry<T>>;
last: any;
size: number;
max: number;
ttl: number;
clear(): void;
delete(key: any): void;
deleteMany(keys: any[]): void;
evict(): void;
expiresAt(key: any): any;
get(key: any): T | undefined;
getMany(keys: any[]): (T | undefined)[];
keys(): string[];
set(key: any, value: T): void;
}
declare class LruMap<T> implements ToadCache<T> {
constructor(max?: number, ttlInMsecs?: number);
first: any;
items: Map<any, T>;
last: any;
max: number;
ttl: number;
size: number;
clear(): void;
delete(key: any): void;
deleteMany(keys: any[]): void;
evict(): void;
expiresAt(key: any): any;
get(key: any): T | undefined;
getMany(keys: any[]): (T | undefined)[];
keys(): IterableIterator<any>;
set(key: any, value: T): void;
}
declare class LruObject<T> implements ToadCache<T> {
constructor(max?: number, ttlInMsecs?: number);
first: any;
items: Record<any, CacheEntry<T>>;
last: any;
size: number;
max: number;
ttl: number;
clear(): void;
delete(key: any): void;
deleteMany(keys: any[]): void;
evict(): void;
expiresAt(key: any): any;
get(key: any): T | undefined;
getMany(keys: any[]): (T | undefined)[];
keys(): string[];
set(key: any, value: T): void;
}
declare class HitStatisticsRecord {
records: Record<string, Record<string, {
expirations: number,
evictions: number,
hits: number,
emptyHits: number,
falsyHits: number,
misses: number,
invalidateAll: number,
invalidateOne: number,
cacheSize: number,
sets: number,
}>>
initForCache(cacheId: string, currentTimeStamp: string): void
resetForCache(cacheId: string): void
}
declare class LruObjectHitStatistics<T> extends LruObject<T>{
constructor(max?: number, ttlInMsecs?: number, cacheId?: string, globalStatisticsRecord?: HitStatisticsRecord, statisticTtlInHours?: number);
}
export {
CacheConstructor,
ToadCache,
LruObject,
LruMap,
FifoMap,
FifoObject,
HitStatisticsRecord,
LruObjectHitStatistics,
FifoObject as Fifo,
LruObject as Lru
}