The ICE Exchange recommends client applications download product definitions only once per day and store them locally in a cache for reuse when the client application restarts. The Handler allows storing, validating, and using data from the product definitions cache file, as recommended by ICE.
The HandlerSettings::productDefinitionCacheDirectory parameter of the HandlerSettings class instructs the Handler where it should store product definitions cache files. By default, the value is empty, indicating that the product definitions cache should be disabled. But if it contains a valid path to a directory where the Handler can create product definitions cache files, the Handler activates the cache logic.
The Handler creates a product definitions cache file for each market subscription. This means that for each MarketSubscription object passed to the Handler::start method, the Handler creates a file with the following name:
<MarketId>-<SecurityType>-<Date>.bin
For example, for market subscription for market type 5 with Futures security type and 1 December 2021, the Handler creates a file with the name:
5-F-2021-12-01.bin
This file contains raw binary data. This data represents the payload received from the TCP connection during the response to the corresponding product definition request. Each product definition's cache file contains data for only one type of security.
Once started, the Handler checks whether any product definition cache files are available. For the given market subscription, it looks for cache files with the current date, and if it finds one, it starts the validation process. The validation includes checking the message type of each message in the file. Also, it includes checking that the number of messages matches the NumOfMarkets field in the first message of the file. If any of these conditions is violated, the Handler ignores the cache file and refreshes it from the network.