class WCC::Data::FaradayClientAppTokenAuth::RedisCache

Constants

DEFAULT_CACHE_KEY

Attributes

cache_key[R]
connection[R]

Public Class Methods

new(connection, cache_key: DEFAULT_CACHE_KEY) click to toggle source
# 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

Public Instance Methods

[](hostname) click to toggle source
# 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) click to toggle source
# 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