The process of cacheing is used to store data frequently demanded and rapidly retrieve it when needed.
The SAP Commerce Region Cache brings the possibility of splitting the content into so called regions. This approach allows as us to control the size allocated to chache specific objects and its eviction strategy.
As we can see in the official documentation SAP Commerce uses the following eviction types:
- Least Recently Used (LRU): The last used timestamp is updated when an element is put into the cache or an element is retrieved from the cache with a GET call.
- Least Frequently Used (LFU): For each GET call on the element, the number of hits is updated. When a PUT call is made for a new element, and assuming that the maximum limit is reached for the memory store, the element with least number of hits, the Less Frequently Used element, is evicted.
- First In, First Out (FIFO): Elements are evicted in the same order as they come in. When a PUT call is made for a new element, and assuming that the maximum limit is reached for the memory store, the element that was placed first (First-In) in the store is the candidate for eviction (First-Out).
More info here
In the further lines we will explore a real example of using a custom Hybris Region Cache.
- Extend
EHCacheRegion
and implement the methods that you need.
|
|
- Configure your new Cache Region. Create a new spring cache configuration file. (ex: devistacore/resources/devistacore-spring-cache.xml)
|
|
After this point you should be able to see your new created cache Region file in HAC Console.
*Don’t forget to add your new created configuration file to the global application context:
devistacore.global-context=devistacore-spring-cache.xml
- Create your cache service
|
|
- Use the sevice where needed
|
|
This is a brief example of using Hybris Region Cache. If you found it usefull make sure to follow us for more:
Devista – Your way into the future!