Monday 25 May 2015

Custom Cache Implementation

Introduction:
                Liferay internally uses EHCache provider for caching mechanism. Normally if we store any object in cache that is expiring after 10 minutes. This is because of default cache declaration in ‘liferay-multi-vm-clustered.xml’.
The path for the above ‘liferay-multi-vm-clustered.xml’ file is,
è  \tomcat-7.0.40\webapps\ROOT\WEB-INF\lib\portal-impl.jar.
Extract the above ‘portal-impl.jar’ file . .
è In ‘Portal-impl\ehcache\liferay-multi-vm-clustered.xml’ the declaration will be as below,
                <defaultCache
                                eternal="false"
                                maxElementsInMemory="10000"
                                overflowToDisk="false"
                                timeToIdleSeconds="600" >  <!-- Time in seconds -->
                                --------------
                </defaultCache>
è In ‘Portal-impl\portal.properties’ the above xml file will be configured as below,

ehcache.multi.vm.config.location=/ehcache/liferay-multi-vm-clustered.xml

Override the default cache:
                To override the default cache behavior i.e., expiration time, Idle time.
1.       Created one folder ‘mycache’ in \tomcat-7.0.40\webapps\ROOT\WEB-INF\classes
2.       Copy the liferay-multi-vm-clustered.xml file from  Portal-impl\ehcache\  and Paste it in \tomcat-7.0.40\webapps\ROOT\WEB-INF\classes\ mycache. There you can change the default behavior as follows,

                 <defaultCache
                                eternal="false"
                                maxElementsInMemory="10000"
                                overflowToDisk="false"
                                timeToIdleSeconds="300"
                             timeToLiveSeconds=”1800”>  <!-- Time in seconds -->
                                --------------
                </defaultCache>

                From the above declaration, stored object in the cache will be expired after 30 minutes. Declared timeToIdleSeconds=”300” means if we don’t access the cache value for 5 minutes it will get expired.

                In case if you want your cache value never get expire just try the following declaration,

                 <defaultCache
                                eternal="false"
                                maxElementsInMemory="10000"
                                overflowToDisk="false"
                                timeToIdleSeconds="0"
                             >  <!-- Time in seconds -->
                                --------------
                </defaultCache>
3.       Configure the above xml file in \tomcat-7.0.40\webapps\ROOT\WEB-INF\classes\portal-ext.properties as follows,

ehcache.multi.vm.config.location=/mycache/liferay-multi-vm-clustered.xml


8 comments:

  1. Really true statement. custom cache implementation directs to cache implements in a right and conventional manner for their users. custom writing service follow this same manner for treating their customer effectively and completely

    ReplyDelete
  2. Thankful to you for explaining the type of cache mechanism used in liferay and it is good to know about its technical side. Best essay writing service reviews uses the same cache mechanism for providing best service.

    ReplyDelete
  3. This is a very nice post that I have found to e very informative. Help With Research. I believe that your explanation is quite comprehensive and easy to understand. Thanks a lot for sharing. Capstone Compiling Service

    ReplyDelete
  4. Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.Web Content Writing Service

    ReplyDelete
  5. Dissertation Guidance Provides quality Online Dissertation Help for students.
    C Assignment Help

    ReplyDelete
  6. This is a great way as it reduces the innocence of plagiarism.
    essay help

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete


  8. Offering the service to a client and providing the support needed to enjoy the same service are things which are very different. Tech support helps the people who are buying the tech products and services have a more tangible use of the products. In addition to that, through such support, there is establishment of good customer relations. Literature Review Editing Experts

    ReplyDelete