web-cache-storage22
v1.0.5
Published
set cache expiration
Downloads
2
Readme
web-cache-storage
web端缓存LocalStorage和SessionStorage设置过期时间以及加密
Node.js (Install)
Requirements:
- Node.js
- npm (Node.js package manager)
npm install web-cache-storage
Usage
import { LocalStorageCache, SessionStorageCache } from 'web-cache-storage';
// 设置 缓存 key = token value = asxwfssf 过期时间 1天(秒)
LocalStorageCache.set('token', 'asxwfssf', 60*60*24);
SessionStorageCache.set('token', 'asxwfssf', 60*60*24);
// 获取值
LocalStorageCache.get('token');
SessionStorageCache.get('token');
Options
import { cacheConfig } from 'web-cache-storage';
cacheConfig({
prefixKey: '', // cache保存键值前缀 默认''
hasEncrypt: true, // 是否开启aes加密 默认 true
key: '_11111000001111@', // aes 加密key 默认 _11111000001111@
iv: '@11111000001111_', // aes 加密iv 默认 @11111000001111_
});