Class: FmRest::TokenStore::Redis

Inherits:
Base
  • Object
show all
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

#options

Instance Method Summary collapse

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(options = {})
  super
  @redis = @options[:redis] || ::Redis.new(options_for_redis)
  @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