Skip to content

支持设置过期时间的本地存储localstorage

Notifications You must be signed in to change notification settings

hjc22/time-localstorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

NPM

npm

time-localstorage

支持设置过期时间的h5 localStorage

在h5的localStorage Api基础上增加了设置过期时间的功能,轻量级

使用方法

# 安装 npm 模块
npm install time-localstorage --save

#项目引入
import timeLocalStorage from 'time-localstorage'

#使用
timeLocalStorage.get('name')/timeLocalStorage.set('name',{a:1},60) ...

Api

方法名 作用 参数 返回值
get 通过key值查询value,如果存储不存在或时间已过期,会返回null [name] 存储的数据,保持存储之前的数据类型
set 存储数据,name为key,value为存储的值value,value无需转化成字符串,time为过期时间,如果time为false,永久存储,单位为秒 [name,value,time]
remove 通过key删除一个存储,和原生removeItem保持一致 [name]
clear 删除所有的本地存储数据,和原生clear保持一致

About

支持设置过期时间的本地存储localstorage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages