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.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 51 def initialize = {} 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
76 77 78 79 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 76 def delete id key = key_for id @redis.del key end |
#load(id) ⇒ Object
64 65 66 67 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 64 def load id key = key_for id @redis.get key end |
#store(id, token) ⇒ Object
70 71 72 73 |
# File 'lib/googleauth/stores/redis_token_store.rb', line 70 def store id, token key = key_for id @redis.set key, token end |