Class CachingRlsLbClient.RlsAsyncLruCache
java.lang.Object
io.grpc.rls.LinkedHashLruCache<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry>
io.grpc.rls.CachingRlsLbClient.RlsAsyncLruCache
- All Implemented Interfaces:
LruCache<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry>
- Enclosing class:
CachingRlsLbClient
private static final class CachingRlsLbClient.RlsAsyncLruCache
extends LinkedHashLruCache<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry>
Implementation of
LinkedHashLruCache for RLS.-
Nested Class Summary
Nested classes/interfaces inherited from interface LruCache
LruCache.EvictionListener<K,V>, LruCache.EvictionType -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRlsAsyncLruCache(long maxEstimatedSizeBytes, LruCache.EvictionListener<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry> evictionListener, com.google.common.base.Ticker ticker, CachingRlsLbClient.RlsLbHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected intReturns estimated size of entry to keep track.protected booleanisExpired(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value, long nowNanos) Determines if the entry is already expired or not.protected booleanshouldInvalidateEldestEntry(RlsProtoData.RouteLookupRequest eldestKey, CachingRlsLbClient.CacheEntry eldestValue, long now) Determines if the eldest entry should be kept or not when the cache size limit is reached.Methods inherited from class LinkedHashLruCache
cache, cleanupExpiredEntries, close, estimatedMaxSizeBytes, estimatedSize, estimatedSizeBytes, fitToLimit, hasCacheEntry, invalidate, invalidateAll, read, resize, updateEntrySize, values
-
Field Details
-
helper
-
-
Constructor Details
-
RlsAsyncLruCache
RlsAsyncLruCache(long maxEstimatedSizeBytes, @Nullable LruCache.EvictionListener<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry> evictionListener, com.google.common.base.Ticker ticker, CachingRlsLbClient.RlsLbHelper helper)
-
-
Method Details
-
isExpired
protected boolean isExpired(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value, long nowNanos) Description copied from class:LinkedHashLruCacheDetermines if the entry is already expired or not.- Specified by:
isExpiredin classLinkedHashLruCache<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry>
-
estimateSizeOf
protected int estimateSizeOf(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value) Description copied from class:LinkedHashLruCacheReturns estimated size of entry to keep track. If it always returns 1, the max size bytes behaves like max number of entry (default behavior).- Overrides:
estimateSizeOfin classLinkedHashLruCache<RlsProtoData.RouteLookupRequest, CachingRlsLbClient.CacheEntry>
-
shouldInvalidateEldestEntry
protected boolean shouldInvalidateEldestEntry(RlsProtoData.RouteLookupRequest eldestKey, CachingRlsLbClient.CacheEntry eldestValue, long now) Description copied from class:LinkedHashLruCacheDetermines if the eldest entry should be kept or not when the cache size limit is reached. Note that LruCache is access level and the eldest is determined by access pattern. -
cacheAndClean
public CachingRlsLbClient.CacheEntry cacheAndClean(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value)
-