New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

smache

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smache

Smart caching module

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

介绍

[sm]art + c[ache] = smache

Smache 是一个方便的内存缓存模块,可以通过一些简单缓存策略避免无限占用更多的内存,同时确保最常用最应该被缓存的对象被缓存。

GitHub: https://github.com/Houfeng/smache

安装

npm install smache --save

用法

const Cache = require('smache');

//创建实例
var cache = new Cache({
  //最多缓存的对象数量,省略时表示不做数量限制
  //在达到最大数量时,会移除「最久没用到的」的缓存项
  max: 1000, 
  //最长缓存生命周期,单位毫秒,省略时表示永久
  //到期时自动移除
  ttl: 1000 * 60 
});

//添加
cache.set(key,value);
cache.set(key,value,ttl); //可以单设定某项的 ttl

//获取
var value = cache.get(key);

//移除
cache.remove(key);

//清空
cache.clear();

Keywords

cache

FAQs

Package last updated on 29 Sep 2016

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