npm: npm install @hapi/catbox-redis

yarn: yarn add @hapi/catbox-redis


The connection can be specified with one (and only one) of:

  • client - a custom Redis client instance where client must:

    • be manually started and stopped,
    • be compatible with the ioredis module API, and
    • expose the status property that must be set to 'ready' when connected.
  • url - a Redis server URL.

  • socket - a unix socket string.

  • cluster - an array of { host, port } pairs.


  • host - a Redis server hostname. Defaults to '' if no other connection method specified from the above.
  • port - a Redis server port or unix domain socket path. Defaults to 6379 if no other connection method specified from the above.

catbox options:

  • partition - a string used to prefix all item keys with. Defaults to ''.

Other supported Redis options:

  • password - the Redis authentication password when required.
  • db - a Redis database name or number.
  • sentinels - an array of { host, port } sentinel address pairs.
  • sentinelName - the name of the sentinel master (when sentinels is specified).
  • tls - an object representing TLS config options for ioredis.


Sample catbox cache initialization:

const Catbox = require('@hapi/catbox');
const CatboxRedis = require('@hapi/catbox-redis');

const cache = new Catbox.Client(CatboxRedis, {
    partition : 'my_cached_data'
    host: '',
    port: 6379,
    db: 0,
    tls: {},

When used in a hapi server (hapi version 18 or newer):

const Hapi = require('hapi')
const CatboxRedis = require('@hapi/catbox-redis');

const server = new Hapi.Server({
    cache : [
            name: 'my_cache',
            provider: {
                constructor: CatboxRedis,
                options: {
                    partition : 'my_cached_data'
                    host: '',
                    port: 6379,
                    db: 0,
                    tls: {},


The test suite expects:

  • a redis server to be running on port 6379
  • a redis server listenning to port 6378 and requiring a password: 'secret'
  • a redis server listenning on socket /tmp/redis.sock
  • a redis cluster contains nodes running on ports 7000 to 7005

See .travis.yml

docker-compose up -d
redis-server &
npm test


Use PSETEX instead of SET and PEXP
Update joi
Example "db" parameter error
Update deps
Allowing empty password
hotfix: redis tls opt is an object, not boolean
breaking changes
Switch to use Redis pexpire
Refactor options
Change module namespace
Don't mess with provided clients
added support for dropSegment
breaking changes
Update to work with Catbox 10 (Hapi 17)
Ensure the client really is ready
Upgrade `ioredis` to `3.x.x`
chore(package): update ioredis to v3
breaking changes
update dependencies
Move to `ioredis`
upgrade code@3 and lab@11
Add option to ignore startup failures
Use `false` parameter to `client.end` in order to fail silently
Adding flush parameter when calling client.end
Test on node v6, update dependencies
breaking changes
Ignore partition if not defined
Allow passing a ready Redis client
Drop node 0.10 support
Add unix socket support
Cleanup tests
Wait redis client to be ready in order to make sure that authentication has been done
Loosen dependency to redis 2.x.x to allow 2.3.0 to match
Upgrade outdated node-redis dependency
Rename spumko to hapijs
Remove large ttl test
Bring coverage back to 100%
Add example