roidrage / redis-session-store

A simple session store for Rails based on Redis.
http://github.com/roidrage/redis-session-store
MIT License
366 stars 147 forks source link

Hiredis with redis-session-store #108

Open codematix opened 6 years ago

codematix commented 6 years ago

How can I use redis-session-store with hiredis? Are there any examples that I can use to understand?

leastbad commented 1 year ago

Assuming that you have the hiredis gem in your Gemfile, just specify it as the driver in your redis options hash.

I pulled this straight from one of my working applications:

  config.session_store :redis_session_store, {
    serializer: :json,
    on_redis_down: ->(*a) { logger.error("Redis down! #{a.inspect}") },
    redis: {
      driver: :hiredis,
      expire_after: 2.weeks,
      key_prefix: "myapp:session:",
      url: ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" }
    }
  }

Sorry if you died before getting this sorted out.

santiagodoldan commented 1 year ago

@leastbad I get ArgumentError: Unknown driver :hiredis, expected one of: '[:ruby]', is there something else other than adding hiredis gem?

santiagodoldan commented 1 year ago

Ok, I figured it out, adding this to your Gemfile fixes above issue

gem 'hiredis-client'