Skip to content

Commit 0566187

Browse files
committed
Expose cache prefix as a constant
Now that `cache_valid_auth` is exposed as a helper it is possible to set a value without duplicating the cache key logic. However, just to be safe this exposes the prefix in a constant in case we need it later.
1 parent f6ac2e5 commit 0566187

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/kracken/controllers/token_authenticatable.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ def request_http_token_authentication(realm = 'Application')
3131

3232
module_function
3333

34+
TOKEN_AUTH_CACHE_PREFIX = "auth/token/"
35+
3436
def cache_valid_auth(token, &generate_cache)
35-
cache_key = "auth/token/#{token}"
37+
cache_key = TOKEN_AUTH_CACHE_PREFIX + token
3638
val = Rails.cache.read(cache_key)
3739
val ||= store_valid_auth(cache_key, &generate_cache)
3840
shallow_freeze(val)

0 commit comments

Comments
 (0)