xl-cache

a cache module based on fileSystem

Usage no npm install needed!

<script type="module">
  import xlCache from 'https://cdn.skypack.dev/xl-cache';
</script>

README

xl-cache

nodejs文件缓存模块

使用方法

  • 添加缓存 set(key,value,[duration]);
    duration 过期时常,单位秒,不传或者传0时缓存不过期
cache.set('test1', 'xialei').then(function() {
//设置缓存成功
}).catch(function(e) {
//设置缓存失败		
});
  • 读取缓存
    get(key);
cache.get('test1').then(function(data) {
    console.log(data);
}).catch(function(e) {
});
  • 删除缓存
    remove(key);
cache.remove('test').then(function() {
//删除成功
}).catch(function(e) {
//删除失败
});
  • 清空缓存
    clean();
cache.clean().then(function() {
//清空成功
}).catch(function(e) {
//清空失败
});

单元测试

npm run test