| Modifier and Type | Class and Description |
|---|---|
static interface |
TryCache.ObjectFactory<T>
Factory interface for creating new objects in TryCache.
|
| Constructor and Description |
|---|
TryCache(TryCache.ObjectFactory<T> factory,
int capacity) |
| Modifier and Type | Method and Description |
|---|---|
T |
acquire()
Acquire an object from the cache or create a new one.
|
void |
clear()
Clear all cached items.
|
long |
getLastUnderflowTime() |
void |
release(T item)
Try to return the item to the cache.
|
void |
shrink(int targetSize) |
int |
size() |
boolean |
wasUnderfilled(long thresholdMillis) |
public TryCache(TryCache.ObjectFactory<T> factory, int capacity)
public T acquire()
public void clear()
public long getLastUnderflowTime()
public void release(T item)
public void shrink(int targetSize)
public int size()
public boolean wasUnderfilled(long thresholdMillis)