How can implement Ehcache in Hybris multi-channel ecommerce suite ? step to implement Ehcache in Hybris

Hybris is provide caching in spilit of content called region and we can configure and add object in each region cache
In Hybris core-cache.xml is heart of caching configuration in Hybris
Suppose we need to implement a another cache region then you need to add below code in core extension spring xml file
<alias alias="cacheRegionsList" name="defaultScenarioCacheRegionList" />
  <bean name="ownProductCacheRegion" class="de.hybris.platform.regioncache.region.impl.EHCacheRegion">
     <constructor-arg name="name" value="ownCacheRegion" />
     <constructor-arg name="maxEntries" value="50000" />
     <constructor-arg name="evictionPolicy" value="LFU" />
     <property name="handledTypes">
         <array>
             <value>1</value>
         </array>
     </property>
  </bean>
 
  <bean id="defaultScenarioCacheRegionList" class="java.util.ArrayList">
                    <constructor-arg>
                        <list>
                             <ref bean="typesystemCacheRegion"/>
                            <ref bean="entityCacheRegion"/>
                            <ref bean="queryCacheRegion"/>
                             <ref bean="ownProductCacheRegion"/>
                        </list>
                    </constructor-arg>
   </bean>
  
  
  
   After add above code you need to access caching by using DefaultCacheController for we need to add below code to access them
  
   @Autowired
 CacheController controller;




 final Collection<CacheRegion> regions = controller.getRegions();
  for (final CacheRegion region : regions)
  {
   if (region.toString().equals("goodyearCacheRegion"))
   {
   
    final Collection<CacheKey> cacheKey = region.getAllKeys();
    for (final CacheKey cach : cacheKey)
    {
     System.out.println(" Cache Region name  " + region.getName() + " Cache key  " + cach.toString());
    
    }
    final CacheStatistics stats = region.getCacheRegionStatistics();
    stats.getHitCount();
    //    (...)
   }
  }

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Implement URL Rewriting in Hybris | Hybris customization

    http://everyreply.com//index.php/284/implement-url-rewriting-in-hybris-hybris-customization

    ReplyDelete

Note: Only a member of this blog may post a comment.