Class: OoAuth::Nonce::RedisStore

Inherits:
AbstractStore show all
Defined in:
lib/oo_auth/nonce/redis_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractStore

remember

Constructor Details

#initialize(options = {}) ⇒ RedisStore

Returns a new instance of RedisStore.



6
7
8
9
10
11
# File 'lib/oo_auth/nonce/redis_store.rb', line 6

def initialize(options = {})
  options.symbolize_keys!
  @namespace = options.delete(:namespace)
  @ttl = options.delete(:ttl) || 15.minutes
  @redis = Redis.new(options)
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



4
5
6
# File 'lib/oo_auth/nonce/redis_store.rb', line 4

def namespace
  @namespace
end

#redisObject (readonly)

Returns the value of attribute redis.



4
5
6
# File 'lib/oo_auth/nonce/redis_store.rb', line 4

def redis
  @redis
end

#ttlObject (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



13
14
15
16
17
18
# File 'lib/oo_auth/nonce/redis_store.rb', line 13

def remember(nonce)
  return nonce if @redis.set(key(nonce), '1', { nx: true, ex: ttl })
  false
rescue Errno::ECONNREFUSED
  false
end