node-cache-helper
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.4 • Public • Published

    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

    Install

    npm i node-cache-helper

    DownloadsWeekly Downloads

    8

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    5.34 kB

    Total Files

    10

    Last publish

    Collaborators

    • mustard-mh