Class: WCC::Data::RackClientAppTokenAuth::RedisCache

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_keyObject (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_lengthObject (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

#connectionObject (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