Class: WCC::Data::RackClientAppTokenAuth::RedisCache
- Inherits:
-
Object
- Object
- WCC::Data::RackClientAppTokenAuth::RedisCache
- Defined in:
- lib/wcc/data/rack_client_app_token_auth.rb
Constant Summary collapse
- DEFAULT_CACHE_KEY =
"org.watermark.wcc-api.client-app-token-cache-store"
- DEFAULT_CACHE_LENGTH =
600
Instance Attribute Summary collapse
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
-
#cache_length ⇒ Object
readonly
Returns the value of attribute cache_length.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #<<(token) ⇒ Object
- #find(token) ⇒ Object
-
#initialize(connection, cache_key: DEFAULT_CACHE_KEY, cache_length: DEFAULT_CACHE_LENGTH) ⇒ RedisCache
constructor
A new instance of RedisCache.
Constructor Details
#initialize(connection, cache_key: DEFAULT_CACHE_KEY, cache_length: DEFAULT_CACHE_LENGTH) ⇒ RedisCache
Returns a new instance of RedisCache.
9 10 11 12 13 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 9 def initialize(connection, cache_key: DEFAULT_CACHE_KEY, cache_length: DEFAULT_CACHE_LENGTH) @connection = connection @cache_key = cache_key @cache_length = cache_length end |
Instance Attribute Details
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
7 8 9 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 7 def cache_key @cache_key end |
#cache_length ⇒ Object (readonly)
Returns the value of attribute cache_length.
7 8 9 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 7 def cache_length @cache_length end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 7 def connection @connection end |
Instance Method Details
#<<(token) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 15 def <<(token) connection.call do |r| r.set join_key(token), "1" r.expire join_key(token), cache_length end end |
#find(token) ⇒ Object
22 23 24 25 26 |
# File 'lib/wcc/data/rack_client_app_token_auth.rb', line 22 def find(token) connection.call do |r| r.get join_key(token) end end |