A driver for caching mongodb with redis
npm install redis-cachingjs
const rm = require('redis-caching');rm({
// host: '/tmp/redis.sock', //unix domain
// host: '127.0.0.1', //can be IP or hostname
port: 6379,
maxRetries: 10, //reconnect retries, default -1 (infinity)
auth: '', //optional password, if needed
db: 0, //optional db selection
autoConnect: true, //will connect after creation
doNotSetClientName: false, //will set connection name (you can see connections by running CLIENT LIST on redis server)
doNotRunQuitOnEnd: false, //when you call
end(), driver tries to send QUIT command to redis before actual end
});`Redis handling
isCached
To check if an key is cached in redis you write the following
`javascript
rm.isCached(key, callback);
`
cache
To cache data you run the following function
`javascript
rm.cache(
key,
document,
settings,
callback
);
`
Settigns could be the following
`javascript
{
forceUpdate: true,
duration: -1
}
`
forceUpdate set to true overwrites the data if already cached
duration is how long the key should be active, -1 is infiniteuncache
To uncache data the following function is called
`javascript
rm.unCache(
key,
settings,
callback
);
`
Settings could be the following
`javascript
{
forceDel: true,
duration: 10
}
``