muc-url-cache

cache url content

Usage no npm install needed!

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

README

//参数
options:{
  timeout: 2000, //线上下载资源的超时时间
  savePath: '/alidata/wk/cache/', // 存在本地的目录
  max: 200, // lru缓存的最大数量
  ttl: 30 * 60 * 1000, // 默认缓存时间
  updateAgeOnGet:true,
}

//示例
const UrlCache = require('muc-url-cache');
const cache = new UrlCache(options);
const result = await cache.get(url);

//result返回结构
{
  data:'xxxx', //url对应的内容
  from:'cache | file | online'  //内容的来源,内存,文件或者线上
}