Class: Angus::Authentication::RedisClient
- Inherits:
-
Object
- Object
- Angus::Authentication::RedisClient
- Defined in:
- lib/angus/authentication/redis_client.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
''
Instance Method Summary collapse
- #add_namespace(key) ⇒ Object
- #get_session_key(key) ⇒ Object
-
#initialize(settings) ⇒ RedisClient
constructor
A new instance of RedisClient.
- #redis ⇒ Object
- #store_session_key(key, data) ⇒ Object
Constructor Details
#initialize(settings) ⇒ RedisClient
Returns a new instance of RedisClient.
10 11 12 13 14 |
# File 'lib/angus/authentication/redis_client.rb', line 10 def initialize(settings) settings = settings.dup @namespace = settings.delete(:namespace) || DEFAULT_NAMESPACE @settings = settings end |
Instance Method Details
#add_namespace(key) ⇒ Object
28 29 30 |
# File 'lib/angus/authentication/redis_client.rb', line 28 def add_namespace(key) "#@namespace.angus-authentication-client.#{key}" end |
#get_session_key(key) ⇒ Object
20 21 22 |
# File 'lib/angus/authentication/redis_client.rb', line 20 def get_session_key(key) redis.get(add_namespace(key)) end |
#redis ⇒ Object
24 25 26 |
# File 'lib/angus/authentication/redis_client.rb', line 24 def redis @redis ||= Redis.new(@settings) end |
#store_session_key(key, data) ⇒ Object
16 17 18 |
# File 'lib/angus/authentication/redis_client.rb', line 16 def store_session_key(key, data) redis.set(add_namespace(key), data) end |