| Modifier and Type | Class | Description |
|---|---|---|
static interface |
TryCache.ObjectFactory<T> |
Something that creates objects of the type cached by this cache
|
| Modifier and Type | Field | Description |
|---|---|---|
protected long |
_lastUnderflow |
|
protected int |
capacity |
|
protected List<T> |
items |
|
protected Lock |
lock |
| Constructor | Description |
|---|---|
TryCache(TryCache.ObjectFactory<T> factory,
int capacity) |
| Modifier and Type | Method | Description |
|---|---|---|
T |
acquire() |
|
void |
clear() |
Clears all cached items.
|
void |
release(T item) |
Tries to return this item to the cache but it may fail if
the cache has reached capacity or it's lock is held by
another thread.
|
protected final int capacity
protected final Lock lock
protected long _lastUnderflow
public TryCache(TryCache.ObjectFactory<T> factory, int capacity)
factory - to be used for creating new instancescapacity - cache up to this many itemspublic T acquire()
public void release(T item)
public void clear()