-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
57 lines (51 loc) · 1.37 KB
/
index.d.ts
File metadata and controls
57 lines (51 loc) · 1.37 KB
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
declare module 'obcachejs' {
export interface CacheOptions {
max?: number;
maxSize?: number;
maxAge?: number;
dispose?: (key: string, value: any) => void;
queueEnabled?: boolean;
reset?: {
interval: number;
firstReset?: number | Date;
};
redis?: {
host?: string;
port?: number;
url?: string;
database?: number;
twemproxy?: boolean;
connectTimeout?: number;
};
id?: number;
}
export interface CacheStats {
hit: number;
miss: number;
reset: number;
pending: number;
}
export interface CachedFunction<T extends (...args: any[]) => any> {
(...args: Parameters<T>): ReturnType<T>;
cacheName: string;
skipArgs?: number[];
}
export interface Cache {
stats: CacheStats;
wrap<T extends (...args: any[]) => any>(
fn: T,
thisobj?: any,
skipArgs?: number[]
): CachedFunction<T> & ((...args: any[]) => Promise<any>);
warmup(fn: CachedFunction<any>, ...args: any[]): void;
invalidate(fn: CachedFunction<any>, ...args: any[]): void;
isReady(): boolean;
}
export function Create(options?: CacheOptions): Cache;
export class CacheError extends Error {}
export const debug: {
register(cache: Cache, name: string): Cache;
view(req: any, res: any, next: () => void): void;
log(callback?: (data: any) => void): void;
};
}