public class UnrefedPooledCache<K,V extends Poolable> extends Object implements PooledCache<K,V>
poll()
is allowed to return unreferenced cache
entries.
You would only use this kind of cache if your objects are interchangeable and have significant allocation cost, and if your memory footprint is somewhat flexible.
Because this class only counts unreferenced objects toward targetSize,
it will have a total memory footprint of:
(targetSize) + (# of threads concurrently writing to cache) +
(total size of still-referenced entries)
Constructor and Description |
---|
UnrefedPooledCache(int targetSize,
float nonPooledFraction) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Purge existing Poolables from the pool+cache.
|
V |
get(K key,
boolean incrementRefCount) |
void |
offer(V value) |
V |
poll() |
V |
put(K key,
V value) |
protected int |
sizeOf(V value) |
String |
toDebugString() |
public UnrefedPooledCache(int targetSize, float nonPooledFraction)
targetSize
- not exactly a max size in practicenonPooledFraction
- the fractional portion in the range [0.0,1.0] of targetSize to
dedicate to non-poolable entriespublic V get(K key, boolean incrementRefCount)
get
in interface PooledCache<K,V extends Poolable>
protected int sizeOf(V value)
public String toDebugString()
toDebugString
in interface PooledCache<K,V extends Poolable>
public void clear()
PooledCache
clear
in interface PooledCache<K,V extends Poolable>