Manage cache in your Node.js app
# install rduk-cache module
npm install rduk-cache --save --save-exact
# install rduk-cache store (here redis)
npm install rduk-cache-store-redis --save --save-exact
- Add a
config.yml
file to your app (more information) - Add a
cacheStore
section (see below for redis configuration)
---
cacheStore:
name: redis
providers:
-
name: redis
type: rduk-cache-store-redis
url: redis://...
var cache = require('rduk-cache');
cache.set('key', {
prop1: 'value 1',
prop2: 'value 2'
})
cache.get('key')
.then(function(obj) {
console.log(obj.prop1); // output: 'value 1'
});