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 express-session
express-session store into
connect-redis to create a
var session = ;var RedisStore = session;app;
A Redis client is required. An existing client can be passed directly using the
client param or created for you using the
clientAn existing client
hostRedis server hostname
portRedis server portno
socketRedis server unix_socket
urlRedis server url
The following additional params may be included:
ttlRedis session TTL (expiration) in seconds. Defaults to session.maxAge (if set), or one day.
disableTTLDisables setting TTL, keys will stay in redis until evicted by other means (overides
dbDatabase index to use. Defaults to Redis's default (0).
passPassword for Redis authentication
prefixKey prefix defaulting to "sess:"
trueto unref the Redis client. Warning: this is an experimental feature.
serializerAn object containing
JSONto override the serializer used
logErrorsWhether or not to log client errors. (default:
true, a default logging function (
console.error) is provided.
false, no logging occurs.
Any options not included in this list will be passed to the redis
createClient() method directly.
Clients other than
node_redis will work if they support the same interface. Just pass the client instance as the
client configuration option. Known supported clients include:
By default, the
node_redis client will auto-reconnect when a connection is lost. But requests may come in during that time. In express, one way this scenario can be handled is including a "session check" after setting up a session (checking for the existence of
If you want to retry, here is another option.