Skip to content

Commit

Permalink
Optimize token caching strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
“v_kkhuang” committed Jan 13, 2025
1 parent d25f96c commit 818e858
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public class ExternalResourceServiceImpl implements ExternalResourceService, Ini
private LoadingCache<String, List<ExternalResourceProvider>> providerCache =
CacheBuilder.newBuilder()
.maximumSize(20)
.expireAfterAccess(1, TimeUnit.HOURS)
.refreshAfterWrite(
.expireAfterWrite(
RMUtils.EXTERNAL_RESOURCE_REFRESH_TIME().getValue().toLong(), TimeUnit.MINUTES)
.build(
new CacheLoader<String, List<ExternalResourceProvider>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CachedTokenService extends TokenService {

private val tokenCache: LoadingCache[String, Token] = CacheBuilder.newBuilder
.maximumSize(TokenConfiguration.TOKEN_CACHE_MAX_SIZE)
.refreshAfterWrite(TokenConfiguration.TOKEN_CACHE_EXPIRE_MINUTES, TimeUnit.MINUTES)
.expireAfterWrite(TokenConfiguration.TOKEN_CACHE_EXPIRE_MINUTES, TimeUnit.MINUTES)
.build(new CacheLoader[String, Token]() {

override def load(tokenName: String): Token = {
Expand Down

0 comments on commit 818e858

Please sign in to comment.