Class: WCC::Data::FaradayClientAppTokenAuth::RedisCache
- Inherits:
-
Object
- Object
- WCC::Data::FaradayClientAppTokenAuth::RedisCache
- Defined in:
- lib/wcc/data/faraday_client_app_token_auth.rb
Constant Summary collapse
- DEFAULT_CACHE_KEY =
"org.watermark.data.client-app-token-cache-store"
Instance Attribute Summary collapse
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #[](hostname) ⇒ Object
- #[]=(hostname, token) ⇒ Object
-
#initialize(connection, cache_key: DEFAULT_CACHE_KEY) ⇒ RedisCache
constructor
A new instance of RedisCache.
Constructor Details
#initialize(connection, cache_key: DEFAULT_CACHE_KEY) ⇒ RedisCache
Returns a new instance of RedisCache.
17 18 19 20 |
# File 'lib/wcc/data/faraday_client_app_token_auth.rb', line 17 def initialize(connection, cache_key: DEFAULT_CACHE_KEY) @connection = connection @cache_key = cache_key end |
Instance Attribute Details
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
15 16 17 |
# File 'lib/wcc/data/faraday_client_app_token_auth.rb', line 15 def cache_key @cache_key end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
15 16 17 |
# File 'lib/wcc/data/faraday_client_app_token_auth.rb', line 15 def connection @connection end |
Instance Method Details
#[](hostname) ⇒ Object
22 23 24 |
# File 'lib/wcc/data/faraday_client_app_token_auth.rb', line 22 def [](hostname) connection.call { |r| r.hget cache_key, hostname } end |
#[]=(hostname, token) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/wcc/data/faraday_client_app_token_auth.rb', line 26 def []=(hostname, token) if token connection.call { |r| r.hset cache_key, hostname, token } else connection.call { |r| r.hdel cache_key, hostname } end end |