A caching lib with simple interface with support for mutiple engines
npm install node-cache-engines --save
// config/cache-profile.js
'use strict'
let CacheProfile = require('node-cache-engines')
// Configure all your CacheProfiles
module.exports = {
'RedisCache': new CacheProfile({
engine: 'redis',
collection: 'default',
expiresSecs: 60 * 60 * 48 // 48 hrs
})
}
// some-service.js
let RedisCache = require('../config/cache').RedisCache
let key = '123'
// Check if key exists in the cache
if (RedisCache.check(key)) {
return RedisCache.read(key)
}
// do work to get your data...
return RedisCache.write(key, data)
Deletes a key out of the cache.
Clear the cache entirely, throwing away all values.
- Fork the project.
- Make your feature addition or bug fix.
- Send me a pull request.