You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "smaheshwar-pltr (via GitHub)" <gi...@apache.org> on 2025/03/10 13:35:09 UTC
Re: [PR] Use Caffeine's `Expiry.writing` for `StorageCredentialCache` [polaris]
smaheshwar-pltr commented on code in PR #1142:
URL: https://github.com/apache/polaris/pull/1142#discussion_r1987299859
##########
polaris-core/src/main/java/org/apache/polaris/core/storage/cache/StorageCredentialCache.java:
##########
@@ -51,39 +51,16 @@ public StorageCredentialCache() {
Caffeine.newBuilder()
.maximumSize(CACHE_MAX_NUMBER_OF_ENTRIES)
.expireAfter(
- new Expiry<StorageCredentialCacheKey, StorageCredentialCacheEntry>() {
- @Override
- public long expireAfterCreate(
- StorageCredentialCacheKey key,
- StorageCredentialCacheEntry entry,
- long currentTime) {
- long expireAfterMillis =
- Math.max(
- 0,
- Math.min(
- (entry.getExpirationTime() - System.currentTimeMillis()) / 2,
- maxCacheDurationMs()));
- return TimeUnit.MILLISECONDS.toNanos(expireAfterMillis);
- }
-
- @Override
- public long expireAfterUpdate(
- StorageCredentialCacheKey key,
- StorageCredentialCacheEntry entry,
- long currentTime,
- long currentDuration) {
- return currentDuration;
- }
-
- @Override
- public long expireAfterRead(
- StorageCredentialCacheKey key,
- StorageCredentialCacheEntry entry,
- long currentTime,
- long currentDuration) {
- return currentDuration;
- }
- })
+ Expiry.writing(
Review Comment:
From [docs](https://github.com/ben-manes/caffeine/blob/d49327cc417d9088a19143394d6c4fb292186c49/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Expiry.java#L120-L138):
> Returns an {@code Expiry} that specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation or replacement of its value. The expiration time is not modified when the entry is read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org