Class: EpoOps::TokenStore::Redis
- Inherits:
-
EpoOps::TokenStore
- Object
- EpoOps::TokenStore
- EpoOps::TokenStore::Redis
- Defined in:
- lib/epo_ops/token_store/redis.rb
Instance Method Summary collapse
-
#initialize(redis_host) ⇒ Redis
constructor
A new instance of Redis.
- #reset ⇒ Object
- #token ⇒ Object
Constructor Details
#initialize(redis_host) ⇒ Redis
Returns a new instance of Redis.
4 5 6 7 8 |
# File 'lib/epo_ops/token_store/redis.rb', line 4 def initialize(redis_host) fail "Please install gems 'redis' and 'connection_pool' to use this feature" unless defined?(::Redis) && defined?(ConnectionPool) @redis = ConnectionPool.new(size: 5, timeout: 5) { ::Redis.new(host: redis_host) } end |
Instance Method Details
#reset ⇒ Object
19 20 21 22 23 |
# File 'lib/epo_ops/token_store/redis.rb', line 19 def reset @redis.with do |conn| conn.del("epo_token_#{id}") end end |
#token ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/epo_ops/token_store/redis.rb', line 10 def token token = nil @redis.with do |conn| token = conn.get("epo_token_#{id}") end token.present? ? OAuth2::AccessToken.new(client, token) : generate_token end |