NCache provides Cache Startup Loader through which cache can be preloaded with data as it starts up. This is useful for applications which depend on certain data and that data should be available to the application immediately after it begins executing. . For example, a video streaming site could have hundreds or thousands of videos at the beginning, and later new videos could be added on the server. For such an application, cache can be preloaded with existing videos on cache startup instead of manually adding the data in it.
To configure cache startup loader, CacheLoader interface provided by NCache needs to be implemented and then deployed using manager. NCache will use that custom provider to load data from the configured data source. Cache can be preloaded by loading data in it either at once or in chunks. On cache startup, NCache framework will iteratively call LoadNext method of this custom provider until it returns false. In this method, logic to return data at once or in multiple chunks can be implemented. The size of the added chunk in cache from data source can also be controlled. In short, NCache provides with flexible ways to load data into cache.
Cache Loader may fail to load data due to an unsuccessful connection with the data source or if an incorrect index is specified while extracting data from the data source. To identify this, server side cache logs for cache loader must be checked for errors/exceptions.
NCache loads data from data source on cache startup and populate it in cache in a separate thread. In case of clustered cache, only the coordinator node will be responsible for loading items in cache. If a node crashes or gets gracefully down while cache loader is in progress, then the next node will be responsible for initiating the cache loader from start.
|
The cache loader process can be delayed for a certain interval through cache loader start up delay configuration. By default its value is 20 seconds and it can be changed by providing NCacheServer.CacheLoaderStartupDelay key along with its value in NCache service XML file.
|
See Also