CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
Showing results for 
Search instead for 
Did you mean: 

Today, in any traditional e-commerce performance and scalability are essential for delivering outstanding customer experience in the ever-changing world of E-commerce.

Ehcache is one of the very essential elements that may greatly improve the efficiency of any commerce platform. To increase response time and system performance, Ehcache an open source, high performance, distributed caching solution, offers effective data caching and minimize database calls.

Why Does SAP Commerce Need Caching

Huge amount of data, including information about the customer, products, inventories and many more things, are processed by SAP commerce, many of these information are rather static over short time periods in any typical e-commerce environment. It can overload the system and slow down response times to repeatedly access the database for unmodified data by frequently accessing data in memory, caching is essential in resolving this issue, it will be possible to response the future request straight from cache instead of fetching from database, which reduce the burden on the database and enhances the system speed.

Ehcache in SAP Commerce

Easy integration between Ehcache and SAP commerce is possible, its offer a reliable and user-friendly caching functionality that’s aids in the speedup the e-commerce site. Ehcache is made to work with Java application and smooth configuration to meet certain caching needs.

Advantage of Ehcache in SAP commerce

  1. Performance Improvement – Ehcache lowers the response times and improves the overall E-commerce by caching frequently requested information. Better user experience is a direct result of faster reaction times, and successful e-commerce depends on this.


  1. Scalability – As E-commerce firm expands, so does the need for scalability and quicker response times. To grow, our caching system horizontally and maintain maximum performance even under heavy loads, Ehcache delivers distributed caching capabilities.


  1. Versatile Configuration- Ehcache provide the numbers of configuration options, letting programmers adjust caching behavior to the specific needs of their SAP commerce application. You may set cache expiration times, eviction rules, and other parameters to customize the caching strategy to your business's needs.


  1. Minimize Data load - Ehcache stop frequent database request call by storing the data that is unmodified for a brief period of time in memory. This lessens the workload on the database and free up the resource for activities that are more important.

How to configure cache

Below are the steps to populate the master address data on the front end for customer registration, so we have implemented Ehcache as a caching solution.

  1. Create Ehcache configuration file in our custom extension, hybris\bin\custom\custom\customccore\resources\config\ehcache.xml

<ehcache xmlns:xsi=""

xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false" monitoring="autodetect"


<diskStore path=""/>

<cache name="addressCache"











  1. Want to use cache functionally in controller. So, create cache configuration file in our custom OCC extension.

hybris\bin\custom\custom\customocc \resources\occ\v2\customocc\web\spring\cache-config-spring.xml

<beans xmlns="" xmlns:xsi=""








<cache:annotation-driven cache-manager="compositecustomOccCacheManager" key-generator="commerceCacheKeyGenerator"/>


<alias name="defaultCompositecustomOccCacheManager" alias="compositecustomOccCacheManager"/>

<bean id="defaultCompositecustomOccCacheManager" class="">

<property name="cacheManagers">

<list merge="true">

<ref bean="defaultcustomOccCacheManager"/>




<alias name="defaultcustomOccCacheManager" alias="customOccCacheManager"/>

<bean id="defaultcustomOccCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">

<property name="cacheManager" ref="customOccEhcache"/>


<alias name="defaultcustomOccEhcache" alias="customOccEhcache"/>

<bean id="defaultcustomOccEhcache" class="de.hybris.platform.webservicescommons.cache.TenantAwareEhCacheManagerFactoryBean">

<property name="configLocation" value="classpath:/cache/customocc-ehcache.xml"/>

<property name="cacheNamePrefix" value="customOccCache"/>




  1. Add the @Cacheable annotation. So, that response from JAVA method is cached.

@Cacheable(value = "addressCache", key = "T(de.hybris.platform.commercewebservicescommons.cache.CommerceCacheKeyGenerator).generateKey(true,true,#fields)")

public AddressMasterListWsDTO getAllPrefecture(@RequestParam(defaultValue = DEFAULT_FIELD_SET)final String fields)


Please refer the below SAP link for more information on Ehcache Configuration.
1 Comment