Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@lgd-utils/cached-storage

LGDHuaOPER19MIT0.0.17TypeScript support: included

一个具有失效功能的缓存存储库

cache, storage, web-storage, cache-storage, memory-storage, util, tool, front-end

readme

@lgd-utils/cached-storage

Bundle size MIT NPM downloads NPM version lodash npm styled with prettier

一个具有失效功能的缓存存储库

Usage

const CachedStorage = require('@lgd-utils/cached-storage').default;

const cachedStorage = new CachedStorage();

cachedStorage.setItem('__TEST_KEY__', '__TEST_VALUE__', 2);

cachedStorage.getItem('__TEST_KEY__'); // '__TEST_VALUE__'
setTimeout (function () {
  cachedStorage.getItem('__TEST_KEY__'); // null
}, 1000 * 60 * 2)

Thanks

灵感来源于 lscache,原库只有 localStorage,现扩展支持 localStorage / sessionStorage / memoryStorage

Contribute

Documentation

changelog