class WCC::Data::RackClientAppTokenAuth::RedisCache

Constants

DEFAULT_CACHE_KEY
DEFAULT_CACHE_LENGTH

Attributes

cache_key[R]
cache_length[R]
connection[R]

Public Class Methods

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

Public Instance Methods

<<(token) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

join_key(suffix) click to toggle source
# File lib/wcc/data/rack_client_app_token_auth.rb, line 30
def join_key(suffix)
  [cache_key, suffix].join(".")
end