README
Wrapper for ioredis.
Overview
The redis module provides promisified redis commands.
Installation
npm install @abeai/node-redis
Instantiation
afterInitialization
hook
With const redis = require('@abeai/node-redis');
redis.init(host, options);
// Will wait until the redis client is created and connected to server
redis.afterInitialization(function() {
redis.client().get('some_key')
.then((value) => {
console.log(value);
})
.catch((err) => {
console.log(err, 'Failed to get some_key');
})
;
});
afterInitialization
hook
Without const redis = require('@abeai/node-redis');
redis.init(host, options);
redis.client().get('some_key')
.then((value) => {
console.log(value);
})
.catch((err) => {
console.log(err, 'Failed to get some_key');
})
;
Interface
init(host[, options])
Creates a new redis client instance.
Options
redis
Key value dictionary of ioredis options.
logger
Custom logger to be used by client.
client()
Returns the redis client instance which includes all standard redis commands via ioredis. The command function names are lowercase and all functions return a promise.
afterInitialization()
Handler attached to the underlying redis client's ready
event. This is only called once when the client connects to the server for the first time.
onReady()
Handler attached to the underlying redis client's ready
event. This is called every time the client connects to the server including reconnects.