node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org ยป



DataCache is a utility module to provide straight-foward functionality to save data to a database (MongoDB for now) with an expiration time and the capacity to update the data at a regular interval.

Quick Examples

    cacheKey:   'someCacheKey',
    expiration: '30',     // In Minutes
    refresh:    '20'      // In Minutes
  }, function(cacheCallback){
  function(err, result){


Releases are available for download from GitHub. Alternatively, you can install using Node Package Manager (npm):

npm install datacache


It's pretty simple. There is just one function call!

load(cacheObj, fn, callback)

Searches the database for a cacheKey and if found, it will return that data. If it's been refresh minutes since the cache was built, it will rebuild the cache after returning the result.

The second fn is what is called to create the data, just pass the final data into the cacheCallback function.

The callback is called with the result from the cache