keep-warm
A utility to maintain an always warm cache refreshed every x seconds
Basic example:
var keepWarm = ; /* Params: * key: a unique string * fetch: a function returning a Promise * interval: cache will be updated every interval ms */; /* 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; /* 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;
Note: This relies on the existence of a global Promise
object as defined in the ECMAScript 6 (Harmony) proposal.