node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »


Connect Redis: Realtime

connect-redis-realtime is an extension of the connect-redis session store.

The difference is, this library is backed by an internal LRU cache to prevent excess network chatter on mildly-stable data. This cache is dynamically expired across nodes via redis built-in pubsub - perfect for realtime apps.

connect-redis is a Redis session store backed by node_redis, and is insanely fast :). Requires redis >= 2.0.0 for the SETEX command.


  $ npm install connect-redis-realtime


  • max An integer containing the maximum number of sessions cacheable - set to at least your maximum-expected concurrent users. Defaults to Infinity.
  • client An existing redis client object you normally get from redis.createClient()
  • host Redis server hostname
  • port Redis server portno
  • ttl Session TTL in seconds
  • db Database index to use
  • pass Password for Redis authentication
  • prefix Key prefix defaulting to "sessions."
  • ... Remaining options passed to the redis createClient() method.


Pass connect to the function connect-redis-realtime exports in order to extend connect.session.Store:

var connect = require('connect')
 	  , RedisStoreRealtime = require('connect-redis-realtime')(connect);

  .use(connect.session({ store: new RedisStoreRealtime(options), secret: 'keyboard cat' }))

Express users may do the following, since express.session.Store points to the connect.session.Store function:

var RedisStoreRealtime = require('connect-redis-realtime')(express);




Thanks to TJ Holowaychuk for connect-redis


Full test coverage.