Package io.grpc.rls
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 ofLinkedHashLruCachefor RLS.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.grpc.rls.LruCache
LruCache.EvictionListener<K,V>, LruCache.EvictionType
-
-
Field Summary
Fields Modifier and Type Field Description private CachingRlsLbClient.RlsLbHelperhelper
-
Constructor Summary
Constructors Constructor Description RlsAsyncLruCache(long maxEstimatedSizeBytes, LruCache.EvictionListener<RlsProtoData.RouteLookupRequest,CachingRlsLbClient.CacheEntry> evictionListener, com.google.common.base.Ticker ticker, CachingRlsLbClient.RlsLbHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CachingRlsLbClient.CacheEntrycacheAndClean(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value)protected intestimateSizeOf(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value)Returns 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 io.grpc.rls.LinkedHashLruCache
cache, cleanupExpiredEntries, close, estimatedMaxSizeBytes, estimatedSize, estimatedSizeBytes, fitToLimit, hasCacheEntry, invalidate, invalidateAll, read, resize, updateEntrySize, values
-
-
-
-
Field Detail
-
helper
private final CachingRlsLbClient.RlsLbHelper helper
-
-
Constructor Detail
-
RlsAsyncLruCache
RlsAsyncLruCache(long maxEstimatedSizeBytes, @Nullable LruCache.EvictionListener<RlsProtoData.RouteLookupRequest,CachingRlsLbClient.CacheEntry> evictionListener, com.google.common.base.Ticker ticker, CachingRlsLbClient.RlsLbHelper helper)
-
-
Method Detail
-
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)
-
-