class

Session::ClusteredRedisStore(T)

Inherits Session::QueryableStore < Session::Store < Reference < Object

A Redis store with local caching and cluster-wide invalidation via pub/sub

This store wraps RedisStore to provide:

  • Local caching layer for reduced Redis load
  • Pub/sub invalidation for multi-node deployments
  • Automatic cache warming on miss
  • Cluster-aware operations

Example:

Session.configure do |config|
  config.cluster.enabled = true
  config.cluster.node_id = ENV["NODE_ID"]? || UUID.random.to_s

  config.store = Session::ClusteredRedisStore(UserSession).new(
    client: Redis.new(host: "redis.example.com")
  )
end

Constructors

new(client : Redis = Redis.new, config : ClusterConfig = ClusterConfig.new)
Source

Instance methods

[](key : String) : T

Core store operations

Source
[]=(key : String, session : T) : T
Source
[]?(key : String) : T | Nil
Source
all_session_ids

Get all session IDs

Source
bulk_delete

Delete all sessions matching a predicate

Source
cache_stats

Get local cache statistics

Source
circuit_breaker
Source
clear
Source
coordinator
Source
delete(key : String)
Source
each_session

Iterate over all sessions matching a predicate

Source
evict_from_cache(key : String) : Bool

Manually evict a session from the local cache (useful for testing)

Source
healthy?

Health check for the underlying Redis store

Source
redis_store
Source
shutdown

Graceful shutdown - stops coordinator and closes Redis connection

Source
size
Source
storage

Storage abstraction - must be implemented by subclasses

Source