npm.io
1.1.10 • Published 5 months ago

@deot/helper-cache

Licence
MIT
Version
1.1.10
Deps
0
Vulns
0
Weekly
0

@deot/helper-cache

缓存管理(Storage / Cookie / IndexedDB

Storage/Cookie/IndexedDB

IndexedDB 返回的是Promise

import { Cookie, Storage, IndexedDB } from '@deot/helper-cache';
// or
import { Cookie, Storage, IndexedDB } from '@deot/helper';

get

Storage.get(key: string, options?: object)

获取缓存中对应的值

  • key: 键值
  • options: 配置项

示例

Storage.get('key');

set

Storage.set(key: string, value: any, options?: object)

设置缓存

  • key: 键值
  • value: 缓存
  • options: 配置项

示例

Storage.set('key', {});

remove

Storage.remove(key: string, options?: object)

清楚缓存

  • key: 键值
  • options: 配置项

示例

Storage.remove('key');

configure

Storage.configure(options: object)

设置版本号

  • options: 配置项

示例

Storage.configure({ version: '1.0.0', keepVersions: [] });