Class: OoAuth::Nonce::RedisStore
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- OoAuth::Nonce::RedisStore
- Defined in:
- lib/oo_auth/nonce/redis_store.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
-
#initialize(**options) ⇒ RedisStore
constructor
A new instance of RedisStore.
- #remember(nonce) ⇒ Object
Methods inherited from AbstractStore
Constructor Details
#initialize(**options) ⇒ RedisStore
Returns a new instance of RedisStore.
6 7 8 9 10 |
# File 'lib/oo_auth/nonce/redis_store.rb', line 6 def initialize(**) @namespace = .delete(:namespace) @ttl = .delete(:ttl) || 15.minutes @redis = Redis.new(**) end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
4 5 6 |
# File 'lib/oo_auth/nonce/redis_store.rb', line 4 def namespace @namespace end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
4 5 6 |
# File 'lib/oo_auth/nonce/redis_store.rb', line 4 def redis @redis end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
4 5 6 |
# File 'lib/oo_auth/nonce/redis_store.rb', line 4 def ttl @ttl end |
Instance Method Details
#remember(nonce) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/oo_auth/nonce/redis_store.rb', line 12 def remember(nonce) return nonce if @redis.set(key(nonce), '1', nx: true, ex: ttl) false rescue Errno::ECONNREFUSED false end |