gmsoft-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

gmsoft-store

前端缓存策略 设置、获取工具

gmsoft-store 前端缓存策略 设置、获取工具

NPM DOWNLOAD

Why

  • 封装了 localStoragesessionStorage 的设置和获取方法;
  • 约定了标识key,当本地存储到达上限无法继续注入时,依照策略清空缓存,便于新的缓存可以注入;
  • 设定全局时效,获取、设置时清空无效数据;

Todo

  • 针对react 封装 hooks
  • 尝试 indexed DB 的封装;

Install


  yarn add gmsoft-store

Api

api 描述 调用 返回 注意
createGroupKey 构造分组key createGroupKey(groupKey: string, itemKey: string) string -
removeLocalStoreBy 调用回调函数,清除对应的 Localstorage removeLocalStoreBy(cb:(key:string)=>boolean) void 警告 操作的范围为任意key
clearLocalStore 清空 通过gmsoft-store创建的非冻结状态的Localstorage数据 clearLocalStore()=>boolean) void -
setLocalStore 创建 Localstorage 数据 setLocalStore(params:SetParams) void -
getLocalStore 获取 Localstorage 数据 setLocalStore(key:string)
setLocalStore(params:GetParams)
any 冻结模式只能用GetParams模式调用
removeSessionStoreBy 调用回调函数,清除对应的 Sessionstorage removeSessionStoreBy(cb:(key:string)=>boolean) void 警告 操作的范围为任意key
clearSessionStore 清空 通过gmsoft-store创建的非冻结状态的Sessionstorage数据 clearSessionStore()=>boolean) void -
setSessionStore 创建 Sessionstorage 数据 setSessionStore(params:SetParams) void -
getSessionStore 获取 Sessionstorage 数据 setSessionStore(key:string)
setSessionStore(params:GetParams)
any 冻结模式只能用GetParams模式调用

Update Log

  • ### 1.0.2
    2019-11-07

    • 🌟 添加 createGroupKey
  • ### 1.0.1
    2019-11-07

    • 🐞 修复 README.md 文档;
    • 🐞 修复 npm 关联 github 代码库地址;
  • ### 1.0.0
    2019-11-07

    • 🛠 重构项目结构;
    • 🌟 添加 Localstorage、Sessionstorage 基础方法;

Readme

Keywords

none

Package Sidebar

Install

npm i gmsoft-store

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

83.3 kB

Total Files

15

Last publish

Collaborators

  • bddandelion