Liferay internally uses EhCache for implementing cache for the database. However it is possible to implement ehcache in our custom code.
You can see the additional knowledge about it here.
But this how the liferay caches the database it is using. Apart form this, we can also use ehcache for our custom implementation. Lets see how this can be done:
Here we have two function setting and getting values in cache. We can import the class and use in our code.
Hope this will help.
Hello Apoorva,
ReplyDeleteI am trying this example to implement caching. But I am getting an exception for the code -
element.SetTimeToLive(CACHE_EXPERIATION_TIME)
"The method setTimeToLive(int) is undefined for the type Element"
Do you have quick fix for this?
Hi Srinath,
DeleteSee the API here. http://ehcache.org/apidocs/net/sf/ehcache/Element.html
Regards,
Apoorva
Hi Apoorva,
ReplyDeleteCan we use this in clustered environment ?
Nope...
Delete