Class: AccessToken::RedisStore
- Inherits:
-
Object
- Object
- AccessToken::RedisStore
- Defined in:
- lib/access_token/redis_store.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #del(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(client = Redis.new) ⇒ RedisStore
constructor
A new instance of RedisStore.
- #key?(key) ⇒ Boolean
- #set(key, value, ttl) ⇒ Object
Constructor Details
#initialize(client = Redis.new) ⇒ RedisStore
Returns a new instance of RedisStore.
5 6 7 |
# File 'lib/access_token/redis_store.rb', line 5 def initialize(client = Redis.new) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/access_token/redis_store.rb', line 3 def client @client end |
Instance Method Details
#del(key) ⇒ Object
20 21 22 |
# File 'lib/access_token/redis_store.rb', line 20 def del(key) client.del(key) end |
#get(key) ⇒ Object
16 17 18 |
# File 'lib/access_token/redis_store.rb', line 16 def get(key) client.get(key) end |
#key?(key) ⇒ Boolean
24 25 26 |
# File 'lib/access_token/redis_store.rb', line 24 def key?(key) client.exists(key) end |
#set(key, value, ttl) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/access_token/redis_store.rb', line 9 def set(key, value, ttl) client.multi do client.set(key, value) client.expire(key, ttl) end end |