Module org.glassfish.hk2.utilities
Class LRUCacheCheapRead<K,V>
java.lang.Object
org.glassfish.hk2.utilities.cache.LRUCache<K,V>
org.glassfish.hk2.utilities.cache.internal.LRUCacheCheapRead<K,V>
- Type Parameters:
K- The key of the cacheV- The values in the cache
LRU Cache implementation that relies on entries that keep
last hit (get/put) timestamp in order to be able to remove least recently
accessed items when running out of cache capacity.
Item order is not being maintained during regular cache usage (mainly reads).
This makes pruning operation expensive in exchange
for making reads quite cheap in a multi-threaded environment.
- Author:
- Jakub Podlesak (jakub.podlesak at oracle.com)
-
Constructor Summary
ConstructorsConstructorDescriptionLRUCacheCheapRead(int maxCacheSize) Create new cache with given maximum capacity. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value associated with the given key.intReturns the maximum number of entries that will be stored in this cacheAdds the given key and value pair into the cachevoidClears all entries in the cache, for use when a known event makes the cache incorrectvoidreleaseMatching(CacheKeyFilter<K> filter) This method will remove all cache entries for which this filter matchesMethods inherited from class org.glassfish.hk2.utilities.cache.LRUCache
createCache
-
Constructor Details
-
LRUCacheCheapRead
public LRUCacheCheapRead(int maxCacheSize) Create new cache with given maximum capacity.- Parameters:
maxCacheSize- Maximum number of items to keep.
-
-
Method Details
-
get
Description copied from class:LRUCacheReturns the value associated with the given key. If there is no value, returns null -
put
Description copied from class:LRUCacheAdds the given key and value pair into the cache -
releaseCache
public void releaseCache()Description copied from class:LRUCacheClears all entries in the cache, for use when a known event makes the cache incorrect- Specified by:
releaseCachein classLRUCache<K,V>
-
getMaxCacheSize
public int getMaxCacheSize()Description copied from class:LRUCacheReturns the maximum number of entries that will be stored in this cache- Specified by:
getMaxCacheSizein classLRUCache<K,V> - Returns:
- The maximum number of entries that will be stored in this cache
-
releaseMatching
Description copied from class:LRUCacheThis method will remove all cache entries for which this filter matches- Specified by:
releaseMatchingin classLRUCache<K,V> - Parameters:
filter- Entries in the cache that match this filter will be removed from the cache. If filter is null nothing will be removed from the cache
-