Class: FmRest::TokenStore::Redis
- Defined in:
- lib/fmrest/token_store/redis.rb
Constant Summary collapse
- DEFAULT_PREFIX =
"fmrest-token:".freeze
- STORE_OPTIONS =
[:redis, :prefix].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #delete(key) ⇒ Object
-
#initialize(options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #load(key) ⇒ Object
- #store(key, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
13 14 15 16 17 |
# File 'lib/fmrest/token_store/redis.rb', line 13 def initialize( = {}) super @redis = @options[:redis] || ::Redis.new() @prefix = @options[:prefix] || DEFAULT_PREFIX end |
Instance Method Details
#delete(key) ⇒ Object
28 29 30 |
# File 'lib/fmrest/token_store/redis.rb', line 28 def delete(key) @redis.del(prefix_key(key)) end |
#load(key) ⇒ Object
19 20 21 |
# File 'lib/fmrest/token_store/redis.rb', line 19 def load(key) @redis.get(prefix_key(key)) end |
#store(key, value) ⇒ Object
23 24 25 26 |
# File 'lib/fmrest/token_store/redis.rb', line 23 def store(key, value) @redis.set(prefix_key(key), value) value end |