wowok
Version:
Wowok Blockchain TypeScript API
36 lines (35 loc) • 1.5 kB
TypeScript
export type CacheExpireType = number | "INFINITE";
export interface CachedData<T = any> {
expire: CacheExpireType;
data: T;
}
export declare enum CachePrefix {
token = "token",
object = "object",
personal = "personal",
table = "table",
config = "config",
local_mark = "mark",
local_info = "info",
event = "event"
}
export interface IStorage {
put(key: string, value: string): Promise<void>;
get(key: string): Promise<string | undefined>;
del(key: string): Promise<void>;
clear(): Promise<void>;
}
export declare class Cache {
static storage: IStorage | null | undefined;
static memory: Map<string, CachedData<any>>;
static setStorage(storage?: IStorage | null | undefined): void;
static hasStorage(): boolean;
static initDefaultStorage(): void;
static notExpired<T>(cache: CachedData<T>): boolean;
static DefaultExpireTime: (bInfinite?: boolean) => CacheExpireType;
private static storeData;
static read<T = any>(key: [string, ...string[]], load: (key: [string, ...string[]]) => CachedData<T> | undefined | Promise<CachedData<T>> | Promise<undefined>, bForceLoad?: boolean): Promise<CachedData<T> | undefined>;
static read_many<T = any>(prefix: string, keys: string[], load: (prefix: string, load_keys: string[]) => Promise<CachedData<T>[]> | Promise<undefined>, bForceLoad?: boolean): Promise<CachedData<T>[]>;
static del(key: [string, ...string[]]): Promise<void>;
static clear(): void;
}