1.0.5 • Published 3 years ago

@baikbingo/cache v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

baikbingo-cache

配置

import { createCache } from "@baikbingo/cache";
const cahce = createCache({
  databaseName: "cache", // 数据库名称
  tableName: "localStorage", // 表名
  memory: true, // 内存接管
  version: 1 // 版本号
});

memory如果关闭内存接管则无法使用所有同步方法

获取缓存操作

// 异步
const cahce = createCache();
cache.get(key).then(res => {
  console.log("结果", res);
});

// 同步
const res = cache.syncGet(key);

// 同步数据是要保证 数据遍历完成情况下才能获取(readAll)
// 所以可以在获取数据之前,重新赋值一下数据
// 在readAll方法下get一定能生效
cache.readAll().then(() => {
  const res = cache.syncGet(key);
});
// 或者
await cache.readAll();
const res = cache.syncGet(key);

异步操作

const cahce = createCache();
cache.set(key, value);
cache.del(key);
cache.clear();

同步操作

const cahce = createCache();
cache.syncSet(key, value);
cache.syncDel(key);
cache.syncClear();

github

https://github.com/zmkwjx/baikbingo-cache
1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta3

4 years ago

1.0.0-beta2

4 years ago

1.0.0-beta1

4 years ago

1.0.0-beta0

4 years ago