lite-ts-cache
TypeScript icon, indicating that this package has built-in type declarations

11.6.2 • Public • Published

Version

代码

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);

Readme

Keywords

Package Sidebar

Install

npm i lite-ts-cache

Weekly Downloads

4

Version

11.6.2

License

GPL-3.0

Unpacked Size

42.4 kB

Total Files

9

Last publish

Collaborators

  • ahl5esoft