1 | import { TeMongoDBUnit } from "./mongodb/TeMongodb";
|
2 | interface ifCacheKeepOption {
|
3 | type: 'unknow' | 'file' | 'mongo';
|
4 | path?: string | TeMongoDBUnit;
|
5 | }
|
6 | export declare class CacheMoudle<T> {
|
7 | private static thread;
|
8 | private static handle;
|
9 |
|
10 | static init(): Promise<void>;
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 | static createCache<T>(name?: string, ttl?: number, keep?: ifCacheKeepOption): CacheMoudle<T>;
|
17 | static removeCache(name: string): void;
|
18 | static update(): Promise<void>;
|
19 | static cacheMap: {
|
20 | [key: string]: CacheMoudle<any>;
|
21 | };
|
22 | valueCache: {
|
23 | [roleId: string]: {
|
24 | time: number;
|
25 | value: T;
|
26 | };
|
27 | };
|
28 | private loader;
|
29 | private getfresh;
|
30 | ttl: number;
|
31 | name: string;
|
32 | private constructor();
|
33 | init(): Promise<boolean>;
|
34 | change: boolean;
|
35 | /**
|
36 | *
|
37 | * @param key
|
38 | * @param value 内容
|
39 | * @param time 当 ttl 大于等于0时设置的当前时间或者不设置,ttl小于0时设置过期的时间
|
40 | */
|
41 | set(key: string, value: T, time?: number): Promise<boolean>;
|
42 | has(key: string): boolean;
|
43 | hasOwnProperty(key: string): boolean;
|
44 | get(key: string): T | undefined;
|
45 | del(key: string): Promise<any>;
|
46 | /**
|
47 | * 遍历内容
|
48 | * @param cb 当方法返回 true时 结束遍历(break)
|
49 | */
|
50 | forEach(cb: (value: T, key: string) => boolean | void): T | undefined;
|
51 | clear(): void;
|
52 | private _update;
|
53 | }
|
54 | export {};
|