datacache

0.1.0 • Public • Published

DataCache

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

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

Download

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

npm install datacache

Documentation

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

Readme

Keywords

none

Package Sidebar

Install

npm i datacache

Weekly Downloads

2

Version

0.1.0

License

none

Last publish

Collaborators

  • shamoons