11.6.1 • Published 4 days ago
lite-ts-cache v11.6.1
代码
CacheBase - 缓存
const cache: CacheBase;
// 清理
await cache.flush('键');
// 获取
const res = await cache.get('键', async () => {
// 加载数据
return [];
});
// res = []
const res = await cache.getModifyOn('键');
// res = 缓存修改时间
- MemoryCache - 内存缓存
const nowTime: NowTimeBase;
const getModifyOnFunc: (key: string) => Promise<number>;
const setModifyOnAction: (key: string, modifyOn: number) => Promise<void>
// 检测缓存是否变更的间隔区间, 默认: [5_000, 60_000]
const checkModifyIntervalRange: [number, number];
const cache = new CacheMemoey(nowTime, getModifyOnFunc, setModifyOnAction, checkModifyIntervalRange);