The CachingInventoryManager
is also included in the Oracle ATG Web Commerce out-of-the-box implementation. The CachingInventoryManager
caches any read-only data for quick display to the site user. It is configured with a Cache
and an UncachedInventoryManager
.
The uncachedInventoryManager
property of the CachingInventoryManager
refers to any implementation of the InventoryManager
API. It is recommended that the uncachedInventoryManager
property refer to an instance of the RepositoryInventoryManager
.
All methods are passed to the UncachedInventoryManager
, except for
queryStocklevel
queryBackorderLevel
queryPreorderLevel
queryAvailabilityStatus
queryAvailabilityDate
queryStockThreshold
queryBackorderThreshold
queryPreorderThreshold
.
These methods work by asking the cache for the item with the requested ID. The needed property value is then read from the cached item.
If a method is called that changes a property of an inventory item, then that item’s cached value is invalidated and will be reloaded the next time it is needed. If the CachingInventoryManager
is used, it should be used for all inventory operations or it could return invalid results. Invalid results could occur if some updates are made directly to the InventoryManager
referred to by the uncachedInventoryManager
property (as opposed to through the CachingInventoryManager
). This is because the changes made outside of the CachingInventoryManager
will not have invalidated the cache.
The flushCache
method flushes the existing cache data. The flushCache
method flushes the entire cache. flushCache(List)
flushes the entry for each ID in list.
The CachingInventoryManager
does not actually perform inventory management. It relies on another implementation of the InventoryManager
interface. Therefore, if you provide your own implementation of the InventoryManager
interface, instant caching can be configured using the CachingInventoryManager
and setting its uncachedInventoryManager
property to your implementation.
InventoryCache
InventoryCache
is the cache used by the CachingInventoryManager
. It can be found at /atg/commerce/inventory/InventoryCache
in the component browser of the ACC. It is an instance of atg.service.cache.Cache
. If the inventory data changes, resulting in stale data in the cache, it is possible to flush the cache. This class includes a public void method flush
that can be accessed through the component browser. It flushes all the entries from the caching. For more information, see the Caching the Inventory section.
The following table describes the properties of the InventoryCache
component that you can use to define your cache policies:
Property | Description |
---|---|
| The maximum number of elements in the cache. If set to 0, nothing will be cached. If set to –1, there is no limit on how many elements can be in the cache. |
| The maximum memory size of the cache. |
| The maximum memory size of a single entry in the cache. |
| The maximum number of milliseconds that an entry will live in the cache. * |
* By default, the maximumEntryLifetime
property is set to 7,200,000 (2 hours) in the live configuration. The Motorprise reference application overrides this value and changes it to 60,000 (1 minute). This frequent update time is recommended during development, so that information will be updated rapidly.