New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cuo9958/local_cache

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cuo9958/local_cache

nodejs双缓存

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

双缓存 nodejs 本地缓存

利用双缓存的优势接管本地缓存。并发情况下避免同时刷新数据的尴尬。

使用方式

初始化

参数maxAge,缓存的存活时间,单位是毫秒。

参数update,本地缓存失效之后的更新方法。

function update() {
    console.log("更新一次");
    return Date.now();
}
const cache = new LocalCache({
    maxAge: 1000,
    update
});

获取值

获取使用的是 Promise 方式,需要处理调用方式。

cache.get("test").then(res => {
    console.log(res);
});

设置值

设置值,参数固定是string,值没有限制。可以提前设置值,避免首次启动的卡顿。

cache.set("test", 123);

FAQs

Package last updated on 20 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc