Skip to content

Commit

Permalink
secret providers: some small fix for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 23, 2024
1 parent 4c6ddc6 commit 444df3b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private <ST> ST getOrResolveSecret(String key, Class<ST> type) throws Encryption
if (value != null) {
LOGGER.trace("Cache hit for key {}", key);

if (Clock.get().currentTimeMillis() <= ttl) {
if (Clock.get().currentTimeMillis() - value.ttl <= ttl) {
LOGGER.trace("Cache entry for key {} is still valid, using cached value", key);

if (value.value == null) {
Expand All @@ -112,7 +112,7 @@ private <ST> ST getOrResolveSecret(String key, Class<ST> type) throws Encryption

if (ttl > 0) {
LOGGER.trace("Caching secret for key {}", key);
cache.put(key, new CacheValue<>(secret, System.currentTimeMillis() + ttl));
cache.put(key, new CacheValue<>(secret, Clock.get().currentTimeMillis() + ttl));
}

return secret;
Expand Down

0 comments on commit 444df3b

Please sign in to comment.