tj / connect-redis

Redis session store for Connect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Are there ways to create, and maintain replicas of session stores?

williamdarkocode opened this issue · comments

Suppose I have an initial redis session store as in the documentation:

const redis = require('redis')
const session = require('express-session')

let RedisStore = require('connect-redis')(session)
let redisClient = redis.createClient()

app.use(
  session({
    store: new RedisStore({ client: redisClient }),
    saveUninitialized: false,
    secret: 'keyboard cat',
    resave: false,
  })
)

And I now want a second session store, on a different host, that is an exact replica of the initial one. I'm working with a microservices architecture, and only one service, the authentication service, actually writes (infrequently) to the session store. However, the remaining services often read (frequently) from the session store. Making all services share the same instance of the redis store, wouldn't be good for the authentication service, which is needed for authenticating users. So, how do I create what is essentially a replica of the initial redis store, for the other services to conduct read operations from?

I've thought about using PubSubs to update the "replica" store as new sessions are added or removed from the initial store. Is this a good solution? Is it even possible?

Any help/clarifications would be helpful; thanks.

Also are there any events emitted when ever a new session is added, for PubSub use cases for instance?

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@williamdarkocode Any progress on this? This library does not emit any pubsub events. But have you tried using the clustering support the redis client has built-in?

This issue was closed because it has been stalled for 5 days with no activity.