The main concern of this article is to present performance enhancing information using Liferay cache.
Liferay has out of box Cache MultiVMPool, which we can implement in our portlet's code for caching of results. It becomes necessary if we are using heavy web services.
MultiVMPool Cache is quite easy to implement even over the clustered environment specially if you're frank with handing objects saved in request and session, its quite similar. When I needed it for implementation, I didn't find anything relevant and that is why I need to contribute this article.
Let's know MultiVMPool Cache !!!
MultiVMPool Cache is an Out of Box Cache provided by Liferay and so such kind of complex server and bean configuration is not needed to change for its implementation : No additional infrastructure configuration needed. It uses the Liferay's EHChache for wrapper services. It can be implemented in clustered environment easily and used cross WARs also (Because its a JVM level Cache).
Putting some value in Cache
There are several other overriden methods also, but most likable is to use the following:
MultiVMPoolUtil.put("Cache-name", "key" ,"value");
NOTE: New cache is automatically created if doesn't exits.
String value = (String) MultiVMPoolUtil.get("Cache-name", "key");
Returns the value of "key" form "cache-name" cache.
Removing one key
Removing one key form a cache.
Clear the cache named "cache-name".
Caching over Clustered environment
Uncomment the following in a clustered environment form portal-ext.properties.
Don't forget to serialize objects so that caching can be synchronized for other network connections also.
Hope this will help you.