The DistributedMap interface is a simple interface for the dynamic cache. Using the DistributedMap interface, J2EE applications and system components can cache and share Java objects by storing a reference to the object in the cache. The default WebSphere dynamic cache instance is created if dynamic cache service is enabled in the administrative console. This default instance is bound into the global JNDI namespace using the name services/cache/distributedmap.
For using the DistributedMap in the code, check out the following snippet
InitialContext ic = new InitialContext();
//lookup the default cache map
DistributedMap map = (DistributedMap)ic.lookup("services/cache/distributedmap ");
//puts the key value pair in cache
map.put(key, value);
//get the value for the passed in key
obj = map.get(key);
Check out my earlier peice on enabling DynaCache in WAS here.
Filed in: WAS
Post a Comment