UNPKG

ipink-util

Version:

util.js

53 lines (52 loc) 1.5 kB
export declare interface IStorage { set: (key: string, value: any, expire?: number | -1) => boolean; setItem: (key: string, value: any, expire?: number | -1) => boolean; get: (key: string) => any; getItem: (key: string) => any; remove: (key: string) => boolean; clear: () => void; genKey: (key: string) => string; setConfig: (option: { id?: string; }) => void; } export declare class Cache implements IStorage { #private; static createInstance(id?: string): Cache; constructor(id?: string); setConfig(option: { id?: string; }): void; /** * @desc 设置缓存 * @param key 存储Key { string } * @param value 存储内容 { any } * @param expire 过期时间( s > 0 ) { number } * @return: boolean */ set(key: string, value: any, expire?: number): boolean; setItem: (key: string, value: any, expire?: number) => boolean; /** * @desc 获取缓存 * @param key 存储Key { string } * @return: any */ get(key: string): any; getItem: (key: string) => any; /** * @desc 删除指定缓存 * @param key 存储Key { string } * @return: boolean */ remove(key: string): boolean; removeItem: (key: string) => boolean; /** * @desc 清除缓存 * @return: boolean */ clear(): boolean; genID(): string; genKey(key: string): string; } /** @desc 单例模式 **/ export declare const Storage: IStorage;