WebSphere Application Server Object Cache

Posted by Unknown on 7:37 PM with 1 comment
WebSphere Application Server provides basic cache functionality for java ee applications.
One cache functionality is the "Object Cache" which allows applications to programatically use a container hosted cache instance. When using WebSphere Application Server Network Deployment the object cache can also be used as a clustered cache (invalidating & replicating). It therefore can be used as an alternative to Infinispan or EhCache.

This object cache can also be used as an 2nd-Level-Cache for Hibernate 3. A Hibernate 4 adapter is currently not available.

How to setup an object cache instance

To create a basic/non-clustered Object Cache navigate to Ressources > Object cache instances > New ...

A Object cache instance can be limited by the amount of items in the cache and by the cache size (in MB). However only the amount of items is mandatory configuration (default is 2000 items).
Click >OK and >Save the Changes.
The ObjectCache can be used programmatically with the DistrubedMap-Interface. Please refer to this ibm knowledge base article for more informationen - it is quite straight forward.
A sample project with a servlet putting and getting values to/from the object cache can be downloaded here. The servlet urls is "http://<host>:<port>/object-cache-test/SimpleServletTest".
To monitor the cache instance you should use the Cache Monitor provided with the WebSphere Application Server.
Go to Applications > New Application > New Enterprise Application and select the CacheMonitor.ear which is located in "WebSphere-Install-Root"/installableApps/CacheMonitor.ear 

Click >Next and select the "Fast Path". The installation does not require any special configurations. After the installation process is finished click >Save.
To actually see the statistics of object cache instances it is nesseccary to extend the basic cache monitor. Whitout this extention the cache monitor is only able to view content of servlet cache instances.
Download the Extended Cache Monitor package for that (IBM-ID needed for download!). For WebSphere Application Server 8.5.5 download the WebSphere Application 7 package (cachemonitor7_package.zip) which should work in most cases.
Extract the cachemonitor7_package.zip.
Go to Applications > WebSphere enterprise applications
Select the Dynamic Cache Monitor Application and select "Update".
Select Replace, add, or delete multiple files and browse to the cachemonitor7_update.zip within the downloaded package and click >Next and >Ok.
When the update process is finished click Save directly to the master configuration.
Restart the application server.
The cache monitor is availiable with the url http://<host>:<port>/cachemonitor


[Images] Cover picture by Markus Spiske (http://www.raumrot.com/)