How do I share Redis key/values across multiple instances with rackup/Sinatra?

178 Views Asked by At

I'm trying to use Redis as my session store, which seem to work just fine. However I can't figure out how to let multiple instances of Sinatra access the same session. This is what I have in my config.ru:

require 'redis-rack'

use Rack::Session::Redis, :redis_server => "redis://#{ENV['REDIS_HOST']}:6379/0"

I must be missing an argument to set this, but the documentation is lacking for this case: https://github.com/redis-store/redis-rack

Maybe that's not what I want to achieve this behavior?

The end goal is to be deploying my Sinatra application with docker to a clustered environment so I can release new versions without downtime. So whatever let's me share the rack session between multiple instances works. I suppose I could create a redis object manually and not use the session keyword, just seems like the wrong way to do it.

0

There are 0 best solutions below