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 of
LinkedHashLruCache
for RLS.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.grpc.rls.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 int
Returns estimated size of entry to keep track.protected boolean
isExpired
(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value, long nowNanos) Determines if the entry is already expired or not.protected boolean
shouldInvalidateEldestEntry
(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 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:LinkedHashLruCache
Determines if the entry is already expired or not.- Specified by:
isExpired
in classLinkedHashLruCache<RlsProtoData.RouteLookupRequest,
CachingRlsLbClient.CacheEntry>
-
estimateSizeOf
protected int estimateSizeOf(RlsProtoData.RouteLookupRequest key, CachingRlsLbClient.CacheEntry value) Description copied from class:LinkedHashLruCache
Returns 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:
estimateSizeOf
in classLinkedHashLruCache<RlsProtoData.RouteLookupRequest,
CachingRlsLbClient.CacheEntry>
-
shouldInvalidateEldestEntry
protected boolean shouldInvalidateEldestEntry(RlsProtoData.RouteLookupRequest eldestKey, CachingRlsLbClient.CacheEntry eldestValue, long now) Description copied from class:LinkedHashLruCache
Determines 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)
-