Hello,
Web sphere has provided very nice feature to cache your objects. Suppose you have some static data in database which does not gets updated frequently, but you need to access that data frequently. You can fetch data once in object and you can cache this object in webspheres DynamicObjectCache, so when required it can fetched from cache reducing expensive db calls.
Lets see how we can configure this cache in Websphere v6.1:
1) Login to admin console
2) Go to Resources -> Cache instances -> Object cache instance
3) Create new cache instance by provinding cache name, jndi name, cache size etc
Using object cache instance in your code:
InitialContext ic = new InitialContext();
DistributedMap dmap = (DistributedMap) ic.lookup("jndiName");
For DistributedMap you need "was-runtime-6.1.0.jar"
Now you can use this map to store and get your objects.
dmap.put("key", object);
dmap.get("key"); ...
Default size of this maps is 2000. You can set desired size from admin console.
More info on object cache setting can be found at :
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/udyn_cacheinstancescollection.html
Detailed article on the object cache can be found at:
http://www.entrepreneur.com/tradejournals/article/117988840_5.html
Thanks,
Anand