Total Pageviews

Tuesday, March 27, 2012

Liferay Cache: a key to improve performance


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).


Implementation
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.


Retriving Value
String value = (String) MultiVMPoolUtil.get("Cache-name", "key");
Returns the value of "key" form "cache-name" cache.


Removing one key
MultiVMPoolUtil.remove("Cache-name", "key");
Removing one key form a cache.


Clearing Cache
MultiVMPoolUtil.clear("Cache-name");
Clear the cache named "cache-name".


Caching over Clustered environment
Uncomment the following in a clustered environment form portal-ext.properties.
    ehcache.multi.vm.config.location=/ehcache/liferay-multi-vm-clustered.xml

Don't forget to serialize objects so that caching can be synchronized for other network connections also.


Hope this will help you.


Ref. docs.liferay.com

Monday, March 12, 2012

Organizations Vs. Communities



Liferay portal is known to have great multi-tenancy support. We know that we can have many independent sites within a single installation of Liferay. This is known "multi-tenancy support". There are two ways to achieve it - Organizations and Communities, and generally people are confused among these two. Lets draw a line among these two:

Community
  1. The users of the portal do not fit in any hierarchy. They are like an ad-hoc group of people and join or leave the group at any point of time.
  2. There is some function or area of interest which cuts across the entire structure of the portal.
 Organization
  1. The users of the portal fit in some sort of hierarchy like the Company-Department-Team.
  2. When a user and the group has very tight coupling, for example, the user cannot join or leave the group at his/her will very easily.
  3. When you have some kind of delegation chain in the hierarchy.
  4. When you want the admin of the group to manage the member's profile.


So, when we've got the line between Organization and Communities, it becomes easier to decide which one to use. Just analyze the scenario.

If we just have to create a website with pages, content and some applications, with no specific access rules and which can be accessed by group of users of the site, then no doubt communities is the best solution.

In addition, if you want to organize users, we should use Organizations, in case.

To Conclude, we can say:
Communities: Communities are basically a way to have groups of pages that can display contents and applications.

Organizations: In Organizations, user can be organized in hierarchy of organizations.