Class CachedMap

java.lang.Object
org.codehaus.plexus.util.CachedMap
All Implemented Interfaces:
Map

public final class CachedMap extends Object implements Map

This class provides cache access to Map collections.

Instance of this class can be used as "proxy" for any collection implementing the java.util.Map interface.

Typically, CachedMap are used to accelerate access to large collections when the access to the collection is not evenly distributed (associative cache). The performance gain is about 50% for the fastest hash map collections (e.g. FastMap). For slower collections such as java.util.TreeMap, non-resizable FastMap (real-time) or database access, performance can be of several orders of magnitude.

Note: The keys used to access elements of a CachedMap do not need to be immutable as they are not stored in the cache (only keys specified by the put(java.lang.Object, java.lang.Object) method are). In other words, access can be performed using mutable keys as long as these keys can be compared for equality with the real map's keys (e.g. same hashCode values).

This implementation is not synchronized. Multiple threads accessing or modifying the collection must be synchronized externally.

This class is public domain (not copyrighted).

Version:
5.3, October 30, 2003
Author:
Jean-Marie Dautelle