public class SoftReferenceCache
extends java.lang.Object
Adding an object is two fold:
If someone requests a key after it has been added but before it has been put they will be blocked until the put.
Modifier and Type | Field and Description |
---|---|
protected java.util.Map |
map
The map of cached objects.
|
Modifier | Constructor and Description |
---|---|
protected |
SoftReferenceCache()
Let people create their own caches.
|
protected |
SoftReferenceCache(boolean synchronous)
Constructs a soft reference cache.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearImpl(java.lang.Object key)
Clear the entry for key.
|
void |
flush()
Let people flush the cache (remove any cached data).
|
protected boolean |
isDoneImpl(java.lang.Object key)
Check if
request(key) will return immediately with the
Object. |
protected boolean |
isPresentImpl(java.lang.Object key)
Check if
request(key) will return with an Object
(not putting you on the hook for it). |
protected void |
putImpl(java.lang.Object key,
java.lang.Object object)
Associate object with key.
|
protected java.lang.Object |
requestImpl(java.lang.Object key)
If this returns null then you are now 'on the hook'.
|
protected final java.util.Map map
protected SoftReferenceCache()
protected SoftReferenceCache(boolean synchronous)
synchronous
- true to enable synchronous mode, false to enable waiting on requestImpl()
until another thread adds the missing objectpublic void flush()
protected final boolean isPresentImpl(java.lang.Object key)
request(key)
will return with an Object
(not putting you on the hook for it). Note that it is possible
that this will return true but between this call and the call
to request the soft-reference will be cleared. So it
is still possible for request to return NULL, just much less
likely (you can always call 'clear' in that case).protected final boolean isDoneImpl(java.lang.Object key)
request(key)
will return immediately with the
Object. Note that it is possible that this will return
true but between this call and the call to request the
soft-reference will be cleared.protected final java.lang.Object requestImpl(java.lang.Object key)
protected final void clearImpl(java.lang.Object key)
protected final void putImpl(java.lang.Object key, java.lang.Object object)
Copyright © 2022 Apache Software Foundation. All Rights Reserved.