This is a plugin to share a common redis connection across the whole Hapi server.
This version is intended for use with hapi v8.x.x
If you are looking for a version that works with hapi v7.x.x then please use version 1.x.x
As of 3.x.x it is now possible to register this plugin multiple times
As of 4.x.x it is now possible to supply a connection string as the
As of 4.x.x
redis is now a peer dependency (0.12.x) to allow users more freedom with redis versions
As of 5.x.x we've scrapped redis as a peer deps
With 6.x.x the
options object has changed it's signature
Registering the plugin
redisLibrary: passing in a
redismodule to override the one bundled with this module. optional.
connection: an object or string that is passed through to basic-redis-factory as the 2nd argument. The relevant part of the docs are reproduced here for ease of reference:
connection can either be a url connection string (i.e
redis://user:email@example.com:6379) or an object.
connection is an object then the factory will look for the following keys on the object
and fallback to defaults for any missing values (host:
6379, no authentication).
url: a url connection string.
host: the host to connect to.
port: the port to connect to.
password: the password to authenticate with, if not supplied then no auth will applied.
opts: an options object as expected by
opts.url is supplied then
opts.password keys will be ignored.
If you wish to use the
hiredis parser then just:
npm install -save hiredis
and this module will automatically use it (unless you override that with the
The registration of this plugin will only complete on either succesful connection to the redis instance or an error.
Using the plugin
Two objects are exposed by this plugin :
client: a redis client connection object that is connected to the redis instance
library: the redis module used by this module