public final class RandomEvictionClientCache<K,V> extends ClientCache<K,V>
ClientCache implementation that pseudo-randomly evicts client cache entries when
the specified size is reached. The intended design is for applications that may have access patterns where a
guaranteed sequence of operations will take place AND the entirety of the sequence of operations cannot fit in the
client cache. This will cause the worst case client cache performance where items are added to the client cache but
never retrieved before they can be evicted.
A concrete example of this is when parallel methods (such as Cache.invoke(String, Duration)) are
used on a namespace with a large number of keys and a client cache that cannot store the entire cache contents. When
an Invoke occurs, the keys for the cache are passed to the CacheEntryReduceHandler or CacheEntryForEachHandler.
These keys will be passed in the same order. An LRU ClientCache implementation can negatively effect performance
in this case by constantly refilling and evicting cache entries while having zero cache hits.
Randomly evicting an entry statistically improves the likelihood of a clientcache read hit.| Constructor and Description |
|---|
RandomEvictionClientCache(int maximumSize) |
RandomEvictionClientCache(int maximumSize,
long randomSeed) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
long |
evictionCount() |
ClientCacheEntry<K,V> |
get(K key)
Retrieve an entry from the client cache.
|
ClientCacheStats |
getStats() |
int |
maximumSize() |
void |
put(ClientCacheEntry<K,V> entry)
Add an element to the client cache.
|
void |
remove(K key)
Remove an entry from the client cache.
|
int |
size() |
public RandomEvictionClientCache(int maximumSize)
public RandomEvictionClientCache(int maximumSize,
long randomSeed)
public void put(ClientCacheEntry<K,V> entry)
ClientCacheput in class ClientCache<K,V>entry - the entry to add.public void remove(K key)
ClientCacheremove in class ClientCache<K,V>key - the key to remove.public ClientCacheEntry<K,V> get(K key)
ClientCacheget in class ClientCache<K,V>key - the key to the entry to retrieve.public int size()
public int maximumSize()
public long evictionCount()
public void clear()
public ClientCacheStats getStats()
getStats in class ClientCache<K,V>