Cache
Cache intercepts calls whenever you access an API (for example ServiceLayer). If you want to get data, it’s either returned from the cache, or retrieved from the database and written to the cache.
When Data Is Cached
-
Caching item attributes:
-
When calling product.getCode(), the underlying data is returned from the cache or, if not yet cached, retrieved, and written to the cache.
-
When calling product.setCode(X) and then save() (for one value) or saveAll() (for multiple values) the cached value is removed (invalidated) from the cache, because it’s no longer valid.
-
-
Caching FlexibleSeach results:
-
When executing a FlexibleSearch query such as SELECT code FROM Product, the result list is cached in the main cache.
-
When a product is removed, then its item data and the cached FlexibleSearch result for such query is removed from the cache.
-
How Data Is Cached
The SAP Commerce Region Cache provides more fine-grained control over your cache configuration. You can define multiple cache regions by specifying their size and eviction strategy, as well as the type instances for which they’re responsible. To find an optimal configuration for your needs, see Region Cache.
When Data Is Removed from Cache
-
The displacement strategy removes the entry from the cache because the cache has reached its maximum size and cannot hold any additional entries. This is done whenever the cache is full and a newer entry is put into the cache.
-
The invalidation strategy detects that the cache entry is no longer valid and doesn’t represent the correct database content. Note the following about invalidation:
-
Inside a single VM, the cache invalidation is done by a method call.
-
When using multiple cluster nodes, the other nodes are notified via TCP or UDP invalidation packets.
-
Invalidation isn’t performed whenever you change something. There are circumstances where the invalidation is delayed, for example when working with transactions. By default, entries modified inside a transaction are invalidated after the transaction.
-
Managing the SAP Commerce Cache
Using the SAP Commerce Administration Console, you can completely clear the cache and monitor cache statistics. Refer to Monitoring Tab for details.