Package net.i2p.util
Class TryCache<T>
java.lang.Object
net.i2p.util.TryCache<T>
- Type Parameters:
 T-
- Direct Known Subclasses:
 ByteCache
An object cache which is safe to use by multiple threads without blocking.
- Since:
 - 0.9.36
 - Author:
 - zab
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSomething that creates objects of the type cached by this cache - 
Field Summary
Fields - 
Constructor Summary
Constructors - 
Method Summary
 
- 
Field Details
- 
capacity
protected final int capacity - 
items
 - 
lock
 - 
_lastUnderflow
protected long _lastUnderflow 
 - 
 - 
Constructor Details
- 
TryCache
- Parameters:
 factory- to be used for creating new instancescapacity- cache up to this many items
 
 - 
 - 
Method Details
- 
acquire
- Returns:
 - a cached or newly created item from this cache
 
 - 
release
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. - 
clear
public void clear()Clears all cached items. This is the only method that blocks until it acquires the lock. 
 -