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 interfaceA Listener notifies cache eviction events.static enumType of cache eviction. -
Method Summary
Modifier and TypeMethodDescriptionPopulates a cache entry.voidclose()Closes underlying resources.intReturns the estimated number of entry of the cache.booleanhasCacheEntry(K key) Returnstrueif given key is cached.invalidate(K key) Invalidates an entry for given key if exists.voidInvalidates cache entries for all keys.Returns cached value for given key if exists, otherwisenull.
-
Method Details
-
cache
-
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.EvictionListenerwithLruCache.EvictionType.EXPLICIT.- Returns:
- the previous value associated with key, otherwise
null
-
invalidateAll
void invalidateAll()Invalidates cache entries for all keys. This operation will triggerLruCache.EvictionListenerwithLruCache.EvictionType.EXPLICIT. -
hasCacheEntry
Returnstrueif 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.
-