| java.lang.Object org.springframework.util.CachingMapDecorator
CachingMapDecorator | abstract public class CachingMapDecorator implements Map,Serializable(Code) | | A simple decorator for a Map, encapsulating the workflow for caching
expensive values in a target Map. Supports caching weak or strong keys.
This class is also an abstract template. Caching Map implementations
should subclass and override the create(key) method which
encapsulates expensive creation of a new object.
author: Keith Donald since: 1.2.2 |
Constructor Summary | |
public | CachingMapDecorator() Create a CachingMapDecorator with strong keys,
using an underlying synchronized Map. | public | CachingMapDecorator(boolean weakKeys) Create a CachingMapDecorator,
using an underlying synchronized Map. | public | CachingMapDecorator(boolean weakKeys, int size) Create a CachingMapDecorator with initial size,
using an underlying synchronized Map. | public | CachingMapDecorator(Map targetMap) Create a CachingMapDecorator for the given Map. |
CachingMapDecorator | public CachingMapDecorator()(Code) | | Create a CachingMapDecorator with strong keys,
using an underlying synchronized Map.
|
CachingMapDecorator | public CachingMapDecorator(boolean weakKeys)(Code) | | Create a CachingMapDecorator,
using an underlying synchronized Map.
Parameters: weakKeys - whether to use weak references for keys |
CachingMapDecorator | public CachingMapDecorator(boolean weakKeys, int size)(Code) | | Create a CachingMapDecorator with initial size,
using an underlying synchronized Map.
Parameters: weakKeys - whether to use weak references for keys Parameters: size - the initial cache size |
CachingMapDecorator | public CachingMapDecorator(Map targetMap)(Code) | | Create a CachingMapDecorator for the given Map.
The passed-in Map won't get synchronized explicitly,
so make sure to pass in a properly synchronized Map, if desired.
Parameters: targetMap - the Map to decorate |
clear | public void clear()(Code) | | |
containsValue | public boolean containsValue(Object value)(Code) | | |
get | public Object get(Object key)(Code) | | Get value for key.
Creates and caches value if it doesn't already exist in the cache.
This implementation is not synchronized: This is highly
concurrent but does not guarantee unique instances in the cache,
as multiple values for the same key could get created in parallel.
Consider overriding this method to synchronize it, if desired.
See Also: CachingMapDecorator.create(Object) |
isEmpty | public boolean isEmpty()(Code) | | |
|
|