Class: OmniAuth::RedisStore
- Inherits:
-
Object
- Object
- OmniAuth::RedisStore
- Defined in:
- lib/omniauth/redis_store.rb
Constant Summary collapse
- OMNIAUTH_REDIS_KEY =
'omniauth.redis_store'
- REDIS_EXPIRE_TIME =
seconds
60
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(env) ⇒ RedisStore
constructor
A new instance of RedisStore.
Constructor Details
#initialize(env) ⇒ RedisStore
Returns a new instance of RedisStore.
15 16 17 |
# File 'lib/omniauth/redis_store.rb', line 15 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
13 14 15 |
# File 'lib/omniauth/redis_store.rb', line 13 def env @env end |
Instance Method Details
#[](key) ⇒ Object
24 25 26 27 28 |
# File 'lib/omniauth/redis_store.rb', line 24 def [] (key) JSON.parse(redis.hget(session_id,key)) rescue TypeError {} end |
#[]=(key, value) ⇒ Object
19 20 21 22 |
# File 'lib/omniauth/redis_store.rb', line 19 def []= (key,value) redis.hset(session_id, key, value.to_json) redis.expire(session_id, REDIS_EXPIRE_TIME) end |
#delete(key) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/omniauth/redis_store.rb', line 30 def delete (key) val = [key] redis.hdel(session_id, key) session.delete(OMNIAUTH_REDIS_KEY) unless redis.exists(session_id) val end |