🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

node-cache-helper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cache-helper

A helper for node-cache

Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
1
-90.91%
Maintainers
1
Weekly downloads
 
Created
Source

NodeCacheHelper

A helper for node-cache

Install

Yarn

yarn add node-cache
yarn add node-cache-helper

NPM

npm install node-cache --save
npm install node-cache-helper --save

Notice

Key DO NOT contain _

Usage

See cache.test.js File

const CacheHelper = require('node-cache-helper')
const singleflight = require('node-singleflight')

let instance = new CacheHelper()

instance.register('Videos', () => singleflight.Do('Videos', someAsyncFuncReturnA))
let d = await instance.get('Videos') // d = A

// With Special Args
// split key with `_` and send them as args of function
async function getUser(id) { return id }
instance.register('User', (id) => singleflight.Do('User_' + id, () => getUser(id)))
let d1 = await instance.get('User_1')   // d1 = 1
let d2 = await instance.get('User_2')   // d2 = 2
let d3 = await instance.get('User_tmp') // d3 = tmp

Keywords

cache

FAQs

Package last updated on 26 Sep 2021

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