class Angus::Authentication::RedisStore
Constants
- DEFAULT_NAMESPACE
- REDIS_POOL_SIZE
- REDIS_POOL_TIMEOUT
Public Class Methods
new(settings)
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 14 def initialize(settings) settings = settings.dup @namespace = settings.delete(:namespace) || DEFAULT_NAMESPACE @pool_size = settings.delete(:pool_size) || REDIS_POOL_SIZE @pool_timeout = settings.delete(:pool_timeout) || REDIS_POOL_TIMEOUT @settings = settings end
Public Instance Methods
add_namespace(key)
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 47 def add_namespace(key) "#@namespace.angus-authentication-provider.#{key}" end
get_session_data(key)
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 33 def get_session_data(key) data = redis.with { |connection| connection.get(add_namespace(key)) } || '{}' JSON(data) end
has_key?(key)
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 22 def has_key?(key) redis.with { |connection| connection.exists(add_namespace(key)) } end
pool_settings()
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 42 def pool_settings { :size => @pool_size, :timeout => @pool_timeout } end
redis()
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 38 def redis @redis ||= ConnectionPool.new(pool_settings) { Redis.new(@settings) } end
save_session_data(key, data, ttl)
click to toggle source
# File lib/angus/authentication/redis_store.rb, line 26 def save_session_data(key, data, ttl) redis.with do |connection| connection.set(add_namespace(key), JSON(data)) connection.expire(add_namespace(key), ttl) end end