class Session::ClusteredRedisStore(T)

Overview

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

This store wraps RedisStore to provide:

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

Included Modules

Defined in:

stores/clustered_redis_store.cr

Constructors

Instance Method Summary

Instance methods inherited from module Session::QueryableStore(T)

all_session_ids : Array(String) all_session_ids, bulk_delete(&predicate : T -> Bool) : Int64 bulk_delete, count_by(&predicate : T -> Bool) : Int64 count_by, each_session(&block : T -> Nil) : Nil each_session, find_by(&predicate : T -> Bool) : Array(T) find_by, find_first(&predicate : T -> Bool) : T | Nil find_first

Instance methods inherited from class Session::Store(T)

[](key : String) : T [], []=(key : String, session : T) : T []=, []?(key : String) : T | Nil []?, authenticate(& : T -> _) : T authenticate, build_cookie(name : String, value : String, host : String = "") : HTTP::Cookie build_cookie, clear clear, create : T create, create_session_cookie(host : String) : HTTP::Cookie create_session_cookie, current_session : T current_session, current_session=(current_session : T) current_session=, current_session? : T | Nil current_session?, delete(key : String)
delete
delete
, encrypts_with_secret? : Bool encrypts_with_secret?, flash : Flash flash, load_from(request_cookies : HTTP::Cookies) : T | Nil load_from, on(event : Symbol, session_id : String, session : T) on, regenerate_id : T regenerate_id, release : Nil release, session_id : String session_id, session_key session_key, set_cookies(response_cookies : HTTP::Cookies, host : String = "") : Nil set_cookies, size : Int64 size, storage : String storage, timeout timeout, valid? : Bool valid?

Constructor Detail

def self.new(client : Redis = Redis.new, config : ClusterConfig = ClusterConfig.new) #

[View source]

Instance Method Detail

def [](key : String) : T #
Description copied from class Session::Store(T)

Core store operations


[View source]
def []=(key : String, session : T) : T #

[View source]
def []?(key : String) : T | Nil #

[View source]
def all_session_ids : Array(String) #
Description copied from module Session::QueryableStore(T)

Get all session IDs


[View source]
def bulk_delete(&predicate : T -> Bool) : Int64 #
Description copied from module Session::QueryableStore(T)

Delete all sessions matching a predicate


[View source]
def cache_stats : LocalCache::CacheStats #

Get local cache statistics


[View source]
def circuit_breaker : CircuitBreaker | Nil #

[View source]
def clear #

[View source]
def coordinator : ClusterCoordinator(T) #

[View source]
def delete(key : String) #

[View source]
def each_session(&block : T -> Nil) : Nil #
Description copied from module Session::QueryableStore(T)

Iterate over all sessions matching a predicate


[View source]
def evict_from_cache(key : String) : Bool #

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


[View source]
def healthy? : Bool #

Health check for the underlying Redis store


[View source]
def redis_store : RedisStore(T) #

[View source]
def shutdown #

Graceful shutdown - stops coordinator and closes Redis connection


[View source]
def size : Int64 #

[View source]
def storage : String #
Description copied from class Session::Store(T)

Storage abstraction - must be implemented by subclasses


[View source]