Socket
Socket
Sign inDemoInstall

keep-warm

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    keep-warm

A utility to maintain an always warm cache refreshed every x seconds


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
130 kB
Created
Weekly downloads
 

Readme

Source

keep-warm

GitHub version NPM Version

Deps Dev Deps Peer Deps

NPM Downloads GitHub stars GitHub forks GitHub issues

A utility to maintain an always warm cache refreshed every x seconds

Basic example:

var keepWarm = require('keep-warm');

/* Params:
 * key: a unique string
 * fetch: a function returning a Promise
 * interval: cache will be updated every interval ms
 */
keepWarm('myKey', function() {
    // does something async and returns a Promise
}, 15000);

/* Params
 * key: the key you originally passed to keepWarm
 * Use when you want the data synchronously and don't care about a failure when the cache has not been initially populated
 */
var myData = keepWarm.get('myKey');

/* Params
 * key: the key you originally passed to keepWarm
 * Use when you want to wait for the cache to be populated if it's not
 */
var myData;
keepWarm.getAsync('myKey').then(function(value) {
    myData = value;
});

Note: This relies on the existence of a global Promise object as defined in the ECMAScript 6 (Harmony) proposal.

Keywords

FAQs

Last updated on 18 Feb 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc