ts-api-core
Version:
Nodejs api framework core
35 lines (34 loc) • 1 kB
TypeScript
import { ClassType } from "../base/type";
/**
* 数据读写接口
*/
export interface UtilsDataStorage {
/**
* 获取数据
*/
getItem: (key: string) => string | undefined;
/**
* 写入数据
*/
setItem: (key: string, value: string | undefined) => void;
}
/** 数据信息, 用以缓存或持久化数据对象 */
export declare class UtilsDB<T> {
private static readonly _instance;
private static readonly _dataStorage;
/** 授权数据 */
private readonly accessData;
private readonly storeKey;
private readonly className;
/**
* 注册数据储器类
* @param classTypeName
* @param storage
*/
registerDataStorage(classTypeName: string, storage: UtilsDataStorage): void;
private getItem;
private setItem;
constructor(classType?: ClassType<T>, className?: string);
get(key: string): Promise<T | undefined>;
set(key: string, data: T): Promise<boolean>;
}