Redis Store

The Redis Store provides persistent, distributed session storage.

Overview

spinner

Usage

Direct Client

Session.configure do |config|
  config.store = Session::RedisStore(UserSession).new(
    client: Redis.new(host: "localhost", port: 6379)
  )
end

RedisStore now supports connection pooling for better resource management:

Session.configure do |config|
  # Using factory method
  pool_config = Session::ConnectionPoolConfig.new(
    size: 20,
    timeout: 2.seconds
  )
  config.store = Session::RedisStore(UserSession).with_pool(pool_config)
end

Or with an existing pool:

Note: PooledRedisStore is deprecated. Use RedisStore.with_pool() instead.

Characteristics

Feature
Value

Storage

Redis server

Max Size

Redis memory

Persistence

Redis persistence

Multi-node

Yes

TTL

Automatic

Best For

  • Production deployments

  • Multi-server architectures

  • Session persistence required

With Encryption

With Circuit Breaker

Health Check

For High Traffic

Consider the Clustered Redis Store for local caching and reduced Redis load.

Last updated

Was this helpful?