Skip to content

Instantly share code, notes, and snippets.

@vanckruz
Forked from bhague1281/cacheExample.js
Created July 22, 2016 00:13
Show Gist options
  • Save vanckruz/5021382c7c6da09576c0c30a3c22f12b to your computer and use it in GitHub Desktop.
Save vanckruz/5021382c7c6da09576c0c30a3c22f12b to your computer and use it in GitHub Desktop.
const NodeCache = require('node-cache');
const cache = new NodeCache();
let data = { results: [] };
// using the cache module to add an object to the cache
cache.set('my-pokemon', data, function(err, success) {
// success will be true if successful
});
// using the cache module to retrieve an object from the cache
cache.get('my-pokemon', function(err, data) {
// data will be the object from the cache, if it exists
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment