org.apache.myfaces.shared_tomahawk.util
Class BiLevelCacheMap
java.lang.Object
   org.apache.myfaces.shared_tomahawk.util.BiLevelCacheMap
org.apache.myfaces.shared_tomahawk.util.BiLevelCacheMap
- All Implemented Interfaces: 
- Map
- public abstract class BiLevelCacheMap 
- extends Object- implements Map
A bi-level cache based on HashMap for caching objects with minimal sychronization
 overhead. The limitation is that remove() is very expensive.
 
 Access to L1 map is not sychronized, to L2 map is synchronized. New values
 are first stored in L2. Once there have been more that a specified mumber of
 misses on L1, L1 and L2 maps are merged and the new map assigned to L1
 and L2 cleared.
 
 
 IMPORTANT:entrySet(), keySet(), and values() return unmodifiable snapshot collections.
 
- Version:
- $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (Wed, 18 Jul 2007) $
- Author:
- Anton Koinov (latest modification by $Author: matzew $)
 
| Nested classes/interfaces inherited from interface java.util.Map | 
| Map.Entry<K,V> | 
 
| Field Summary | 
| protected  Map | _cacheL1To preinitialize
 _cacheL1with default values use an initialization block | 
 
 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
 
_cacheL1
protected Map _cacheL1
- To preinitialize _cacheL1with default values use an initialization block
 
 
BiLevelCacheMap
public BiLevelCacheMap(int mergeThreshold)
isEmpty
public boolean isEmpty()
- 
- Specified by:
- isEmptyin interface- Map
 
- 
 
clear
public void clear()
- 
- Specified by:
- clearin interface- Map
 
- 
 
containsKey
public boolean containsKey(Object key)
- 
- Specified by:
- containsKeyin interface- Map
 
- 
 
containsValue
public boolean containsValue(Object value)
- 
- Specified by:
- containsValuein interface- Map
 
- 
 
entrySet
public Set entrySet()
- 
- Specified by:
- entrySetin interface- Map
 
- 
 
get
public Object get(Object key)
- 
- Specified by:
- getin interface- Map
 
- 
 
keySet
public Set keySet()
- 
- Specified by:
- keySetin interface- Map
 
- 
 
put
public Object put(Object key,
                  Object value)
- If key is already in cacheL1, the new value will show with a delay,
 since merge L2->L1 may not happen immediately. To force the merge sooner,
 call size().
 
- 
- Specified by:
- putin interface- Map
 
- 
 
putAll
public void putAll(Map map)
- 
- Specified by:
- putAllin interface- Map
 
- 
 
remove
public Object remove(Object key)
- This operation is very expensive. A full copy of the Map is created
 
- 
- Specified by:
- removein interface- Map
 
- 
 
size
public int size()
- 
- Specified by:
- sizein interface- Map
 
- 
 
values
public Collection values()
- 
- Specified by:
- valuesin interface- Map
 
- 
 
newInstance
protected abstract Object newInstance(Object key)
- Subclasses must implement to have automatic creation of new instances
 or alternatively can use put to add new items to the cache.
 Implementing this method is prefered to guarantee that there will be only
 one instance per key ever created. Calling put() to add items in a multi-
 threaded situation will require external synchronization to prevent two
 instances for the same key, which defeats the purpose of this cache
 (put() is useful when initialization is done during startup and items
 are not added during execution or when (temporarily) having possibly two
 or more instances of the same key is not of concern).
 
 
- 
 
- 
- Parameters:
- key- lookup key
- Returns:
- new instace for the requested key
 
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.