|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.softamis.net.cache.impl.MapBasedCache<K,V>
K
- type of keys used to identify cache itemsV
- type of values stored in the cachepublic class MapBasedCache<K extends java.io.Serializable,V extends java.io.Serializable>
Generic implementation of simple cache. It uses java.util.Map as underlying storage for items stored in the cache.
Field Summary | |
---|---|
protected java.lang.Object |
fCacheLock
Object used as lock to control access to cache' data |
protected java.util.Map<K,V> |
fData
Map that contains item stored in the cache |
protected static org.apache.commons.logging.Log |
fLog
|
Constructor Summary | |
---|---|
MapBasedCache()
|
Method Summary | |
---|---|
void |
clear()
Clears cache content |
protected void |
doAfterObjectAdded(K aKey,
V aValue)
Method called after adding object to the cache. |
protected void |
doAfterUpdate()
Method called after cache updates. |
java.util.Set<K> |
getKeys()
Returns set of keys for items stored in cache |
V |
getObject(K aKey)
Returns object from cache for given key |
java.util.Set<V> |
getValues()
Returns items stored in the cache |
void |
saveObject(K aKey,
V aValue)
Stores object in cache |
int |
size()
Returns amount of items stored in cache |
void |
update(java.util.Map<K,V> aData)
Updates content of cache by given values (old values will be removed) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log fLog
protected final java.lang.Object fCacheLock
protected java.util.Map<K extends java.io.Serializable,V extends java.io.Serializable> fData
Constructor Detail |
---|
public MapBasedCache()
Method Detail |
---|
public void saveObject(K aKey, V aValue)
SimpleCache
saveObject
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
aKey
- key of objectaValue
- item valueprotected void doAfterObjectAdded(K aKey, V aValue)
aKey
- key of itemaValue
- item addedprotected void doAfterUpdate()
public V getObject(K aKey)
SimpleCache
getObject
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
aKey
- key of the object
null
if there is
no item in the cache for given keypublic void clear()
SimpleCache
clear
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
public void update(java.util.Map<K,V> aData)
SimpleCache
update
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
aData
- new content of the cachepublic int size()
SimpleCache
size
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
public java.util.Set<V> getValues()
SimpleCache
getValues
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
public java.util.Set<K> getKeys()
SimpleCache
getKeys
in interface SimpleCache<K extends java.io.Serializable,V extends java.io.Serializable>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |