Class: Google::Auth::Stores::RedisTokenStore
- Inherits:
-
TokenStore
- Object
- TokenStore
- Google::Auth::Stores::RedisTokenStore
- Defined in:
- lib/googleauth/stores/redis_token_store.rb
Overview
Implementation of user token storage backed by Redis. Tokens
are stored as JSON using the supplied key, prefixed with
g-user-token:
Constant Summary collapse
- DEFAULT_KEY_PREFIX =
"g-user-token:".freeze
Instance Method Summary collapse
- #delete(id) ⇒ Object
-
#initialize(options = {}) ⇒ RedisTokenStore
constructor
Create a new store with the supplied redis client.
- #load(id) ⇒ Object
- #store(id, token) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RedisTokenStore
Note:
If no redis instance is provided, a new one is created and
the options passed through. You may include any other keys accepted
by Redis.new
Create a new store with the supplied redis client.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 36 def initialize = {} super() redis = .delete :redis prefix = .delete :prefix @redis = case redis when Redis redis else Redis.new end @prefix = prefix || DEFAULT_KEY_PREFIX end |
Instance Method Details
#delete(id) ⇒ Object
62 63 64 65 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 62 def delete id key = key_for id @redis.del key end |
#load(id) ⇒ Object
50 51 52 53 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 50 def load id key = key_for id @redis.get key end |
#store(id, token) ⇒ Object
56 57 58 59 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 56 def store id, token key = key_for id @redis.set key, token end |