static class KerberosUtil.SoftCache extends Object
Modifier and Type | Class and Description |
---|---|
private class |
KerberosUtil.SoftCache.LRUHashMap
A linked hash map that implements LRU replacement policy
|
private static class |
KerberosUtil.SoftCache.ValueCell
An instance of this class maintains a reference to a key,
and a soft reference to the value the key maps to.
|
Modifier and Type | Field and Description |
---|---|
private KerberosUtil.SoftCache.LRUHashMap |
hash
Internal hash map used to store the actual key value pairs
|
private ReferenceQueue |
queue
Reference queue for cleared ValueCells
|
Constructor and Description |
---|
KerberosUtil.SoftCache()
Construct an instance of the SoftCache, using a default
capacity of 8.
|
KerberosUtil.SoftCache(int maxCacheSize)
Construct an instance of the SoftCache with the given
size limit.
|
KerberosUtil.SoftCache(int maxCacheSize,
int initialCapacity)
Construct an instance of the SoftCache with the given
size limit and initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all entries in this cache.
|
Object |
get(Object key)
If there is a mapping in this cache for the specified key,
and the softly referenced value of the mapping has not been
garbage collected, return the value, other wise, return
null.
|
private void |
processQueue()
Process the internal ReferenceQueue
|
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in
this cache.
|
Object |
remove(Object key)
Removes the mapping for this key from this cache if it
still exists.
|
private final KerberosUtil.SoftCache.LRUHashMap hash
private ReferenceQueue queue
KerberosUtil.SoftCache()
KerberosUtil.SoftCache(int maxCacheSize)
maxCacheSize
- maximum number of entries allowed in
this cacheKerberosUtil.SoftCache(int maxCacheSize, int initialCapacity)
maxCacheSize
- maximum number of entries allowed in
this cacheinitialCapacity
- initial capacity of the cachepublic Object put(Object key, Object value)
key
- key with which the specified value is to be
associated.value
- - value to be associated with the specified
key, only a soft reference is maintained to value in
this cache.public Object get(Object key)
key
- - key whose associated value is to be returned.public Object remove(Object key)
key
- key whose mapping is to be removed from the cache.public void clear()
private void processQueue()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.