Coder Social home page Coder Social logo

cache-helper's Introduction

Cache Helper

使用 persistentStore 的缓存工具,支持缓存过期时间功能。

使用

可以直接把 index.min.js 文件内容拷贝到脚本中,也可以通过 npm 安装。

npm i persistent-store-cache-helper

pnpm add persistent-store-cache-helper
import cache_read from "persistent-store-cache-helper";
let result = "";
!(async () => {
  result = await cache_read(
    "cache_helper_test",
    "https://github.com/yy4382/cache-helper/raw/main/README.md"
  );
})().finally(() => {
  $done({ body: result });
});

API

暴露了 cache_read 方法。

参数

key {String}

缓存的键。

url {String}

获取数据的 URL。

maxAge {Number}

缓存的最大时间,单位为秒。可选。0 表示每次都重新获取。 -1 表示永不过期。

在每次获取缓存时,会检查缓存是否过期。如果过期,会重新获取数据。

默认为 3600。

expireInfoKey {String}

用于存储过期信息的键。可选。默认为 json.cacheHelper.expireInfo。无特殊需要不必更改。

返回值

Promise<string>

返回一个 Promise 对象,resolve 时返回缓存的数据。

cache-helper's People

Contributors

yy4382 avatar

Stargazers

xream avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.