|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.cache.total.AbstractTotalCache | +--org.sape.carbon.services.cache.total.ReadOnlyCache
This Total Cache implementation is intended for fast
reading of data which expires periodically as a whole. This implementation
is optimized for read operations. All operations on the Map interface
that could modify the cache are not supported and throw
UnsupportedOperationException
.
Two hashmaps are used during the operation of the cache. The activeMap is the active map which is used to service all get requests for the cache. The holdingMap is used to reinitialize the cache. A call to initializeHoldingCache() creates a new holding map. The new map is then filled with all the information from the data loader. Then activateHoldingCache() atomically replaces the activeMap with the holdingMap and dereferences the old activeMap for garbage collection.
Copyright 2003 Sapient
Field Summary | |
private Map |
activeMap
The active map the cache queries against. |
private TotalCacheDataLoader |
dataLoader
Holds the dataloader for this cache. |
private Map |
holdingMap
A background map used for reloading the cache to minimize synchronization time. |
private org.apache.commons.logging.Log |
log
The handle to Apache-commons logger |
Constructor Summary | |
ReadOnlyCache()
|
Method Summary | |
private void |
activateHoldingCache()
Replace the activeMap with the holdingMap |
void |
clear()
Removes all mappings from this cache. |
void |
configure(ComponentConfiguration configuration)
Configure the component. |
Set |
entrySet()
Returns a set view of the mappings contained in this cache. |
protected Map |
getCacheMap()
Returns a referench to the Map that contains all the cached data. |
private void |
initializeHoldingCache()
Initialize the holdingMap |
Set |
keySet()
Returns the keys of the cache. |
Object |
put(Object key,
Object value)
Put the Object value into the cache referenced by the Object key |
void |
putAll(Map t)
Copies all of the mappings from the specified map to this cache. |
void |
refreshAll()
Refresh the contents of the cache. |
Object |
remove(Object key)
Removes the mapping for this key from this cache. |
Collection |
values()
Returns a collection view of the values contained in this cache. |
Methods inherited from class org.sape.carbon.services.cache.total.AbstractTotalCache |
containsKey, containsValue, get, isEmpty, resume, runScheduledTask, size, start, stop, suspend |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Field Detail |
private org.apache.commons.logging.Log log
private Map activeMap
private Map holdingMap
private TotalCacheDataLoader dataLoader
Constructor Detail |
public ReadOnlyCache()
Method Detail |
public void refreshAll() throws CacheLoadException
refreshAll
in interface Cache
refreshAll
in class AbstractTotalCache
CacheLoadException
- when its data loader has failed to load datapublic void configure(ComponentConfiguration configuration)
Configurable
configure
in interface Configurable
configuration
- the configuration for this componentConfigurable.configure(ComponentConfiguration)
public Set entrySet()
AbstractTotalCache
entrySet
in interface Map
entrySet
in class AbstractTotalCache
Map.entrySet()
public Set keySet()
AbstractTotalCache
keySet
in interface Map
keySet
in class AbstractTotalCache
Map.keySet()
public Collection values()
AbstractTotalCache
values
in interface Map
values
in class AbstractTotalCache
Map.values()
public void clear()
AbstractTotalCache
clear
in interface Map
clear
in class AbstractTotalCache
UnsupportedOperationException
- this is a read-only cache,
modification methods are not supportedMap.clear()
public Object put(Object key, Object value)
AbstractTotalCache
put
in interface Map
put
in class AbstractTotalCache
key
- the key to add to the mapvalue
- the value to add for the key
UnsupportedOperationException
- this is a read-only cache,
modification methods are not supportedMap.put(Object, Object)
public void putAll(Map t)
AbstractTotalCache
putAll
in interface Map
putAll
in class AbstractTotalCache
t
- the map to place into the cache
UnsupportedOperationException
- this is a read-only cache,
modification methods are not supportedMap.putAll(Map)
public Object remove(Object key)
AbstractTotalCache
remove
in interface Map
remove
in class AbstractTotalCache
key
- the key to remove from this map
UnsupportedOperationException
- this is a read-only cache,
modification methods are not supportedMap.remove(Object)
protected Map getCacheMap()
AbstractTotalCache
getCacheMap
in class AbstractTotalCache
AbstractTotalCache.getCacheMap()
private void activateHoldingCache()
Replace the activeMap with the holdingMap
private void initializeHoldingCache()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |