Caching is used throughout the system to guarantee quick access to information and reduce the load on the system. All catalog entries are cached and can be accessed without making calls to Elasticsearch after initial calls are made.
Two types of data are cached in Commerce IO: catalog (product and category) and user data.
Catalog cache configuration
You can find the classes used for product and category caching in the
The main class containing cache configuration is
createStoreCache method creates the cache and sets the expiration time to 3,600 seconds. From that point on, every request for a product or category in the
StoreDataSource class is cached. The cache is invalidated in the
indexCatalogAndProduct method of the
CatalogIndexerImpl class on every successful index operation.
To be able to work with internationalized data, the external provider information for every international property is included in the cache as
valuesForLazyProperties map in the model class. These values are resolved at run time in the
geti18nPropertyValues method of
StoreDataSource. If the product or category is already cached in one language and you try to access it in a language that does not have a map entry, Elasticsearch will be queried again.
User cache configuration
You can find the class used for user caching in the Commerce IO SAP Hybris Customer Provider module. The cache is created inside
createHybrisCache method with an expiration time of 90,000 seconds. That expiration time is the default expiration time for a Hybris token. The cache is used in the
Checking the cache
You can explore the cache in tools by navigating to
<your host>/modules/tools/index.jsp and clicking on Cache management. You will see 4 caches that belong to Commerce I/O:
HybrisUserCacheuses userId as a key.
HybrisGroupsCacheis not used by the system but can be utilized to enhance caching features.
StoreProductCachekeys contain information about the environment, specifically the Elasticsearch connection name and index prefix separated by an underscore, and product codes and has the following structure:
<connection name>_<prefix>p<product code>.
StoreCategoryCacheuses similar key structures as above with minor exceptions. Product code is replaced by category path,
pis replaced by
<connection name>_<prefix>_categories_c<category path>