Class: Mach::Persistence::RedisStore
- Inherits:
-
DeltaAndNonceStore
- Object
- DeltaAndNonceStore
- Mach::Persistence::RedisStore
- Defined in:
- lib/mach/persistence/redis_store.rb
Instance Method Summary collapse
- #add_delta(credential_id, delta_value, expires_in) ⇒ Object
- #add_nonce(credential_id, nonce_value, expires_in) ⇒ Object
- #find_delta_by(credential_id) ⇒ Object
- #find_nonce_by(credential_id, nonce_value) ⇒ Object
-
#initialize(options = {}) ⇒ RedisStore
constructor
A new instance of RedisStore.
Methods inherited from DeltaAndNonceStore
Constructor Details
#initialize(options = {}) ⇒ RedisStore
Returns a new instance of RedisStore.
9 10 11 12 13 |
# File 'lib/mach/persistence/redis_store.rb', line 9 def initialize( = {}) raise Mach::Error::MissingConfigurationOptionError unless [:host] && [:port] @redis = Redis.new(:host => [:host], :port => [:port]) @key_namespace = [:key_namespace] || "" end |
Instance Method Details
#add_delta(credential_id, delta_value, expires_in) ⇒ Object
19 20 21 22 |
# File 'lib/mach/persistence/redis_store.rb', line 19 def add_delta(credential_id, delta_value, expires_in) @redis.setex(delta_key_for(credential_id), expires_in, delta_value) delta_value end |
#add_nonce(credential_id, nonce_value, expires_in) ⇒ Object
28 29 30 |
# File 'lib/mach/persistence/redis_store.rb', line 28 def add_nonce(credential_id, nonce_value, expires_in) @redis.setex(nonce_key_for(credential_id, nonce_value), expires_in, 1) end |
#find_delta_by(credential_id) ⇒ Object
15 16 17 |
# File 'lib/mach/persistence/redis_store.rb', line 15 def find_delta_by(credential_id) @redis.get(delta_key_for(credential_id)) end |
#find_nonce_by(credential_id, nonce_value) ⇒ Object
24 25 26 |
# File 'lib/mach/persistence/redis_store.rb', line 24 def find_nonce_by(credential_id, nonce_value) @redis.get(nonce_key_for(credential_id, nonce_value)) end |