基于storage开发缓存库 si-store.js

码农软件 · 软件分类 · HTML5开发相关 · 2019-03-07 07:58:55

软件介绍

一个基于 Web Storage 的存储库,提供简单的 api 操作,可以设置缓存时间。

示例代码:

import store from 'si-store'  // ES6 可以这么写

var store = require('si-store') // commonJs 规范写法

// 如果是script 标签引入的可以不用管,直接使用store对象即可

store.set('test1', 'this is value')  // 存储字符串
store.set('test2', {
  key: 'this is test'
})                                   // 也可以存储对象

store.get('test1')                   //  获取存储的值 this is value

store.remove('test2')                // 删除key为 test2的存储

设置缓存时间

store.set('test', 'test value',  30)   // 设置过期时间在30ms之后

setTimeout(function () {
  store.get('test')                    // null
}, 31)

本文地址:https://codercto.com/soft/d/801.html

Mastering Bitcoin

Mastering Bitcoin

Andreas M. Antonopoulos / O'Reilly Media / 2014-12-20 / USD 34.99

Mastering Bitcoin tells you everything you need to know about joining one of the most exciting revolutions since the invention of the web: digital money. Bitcoin is the first successful digital curren......一起来看看 《Mastering Bitcoin》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具