Package io.grpc.rls
Interface LruCache<K,V>
- All Known Implementing Classes:
CachingRlsLbClient.RlsAsyncLruCache
,LinkedHashLruCache
interface LruCache<K,V>
An LruCache is a cache with least recently used eviction.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A Listener notifies cache eviction events.static enum
Type of cache eviction. -
Method Summary
Modifier and TypeMethodDescriptionPopulates a cache entry.void
close()
Closes underlying resources.int
Returns the estimated number of entry of the cache.boolean
hasCacheEntry
(K key) Returnstrue
if given key is cached.invalidate
(K key) Invalidates an entry for given key if exists.void
Invalidates cache entries for all keys.Returns cached value for given key if exists, otherwisenull
.
-
Method Details
-
cache
Populates a cache entry. If the cache entry for given key already exists, the value will be replaced to the new value.- Returns:
- the previous value associated with key, otherwise
null
-
read
Returns cached value for given key if exists, otherwisenull
. This operation doesn't return already expired cache entry. -
invalidate
Invalidates an entry for given key if exists. This operation will triggerLruCache.EvictionListener
withLruCache.EvictionType.EXPLICIT
.- Returns:
- the previous value associated with key, otherwise
null
-
invalidateAll
void invalidateAll()Invalidates cache entries for all keys. This operation will triggerLruCache.EvictionListener
withLruCache.EvictionType.EXPLICIT
. -
hasCacheEntry
Returnstrue
if given key is cached. -
estimatedSize
Returns the estimated number of entry of the cache. Note that the size can be larger than its true size, because there might be already expired cache. -
close
void close()Closes underlying resources.
-