Configure Cache Startup Loader and Refresher
- This feature is only available in NCache Enterprise Edition.
- Before configuring cache loader and refresher, make sure that the cache is stopped.
Cache startup loader/refresher can be configured in following ways:
Using NCache Web Manager
Launch NCache Web Manager by browsing to
<server-ip>:8251(Windows + Linux).
In the left navigation bar, click on Clustered Caches or Local Caches based on the cache to configure.
Against the cache name, click on View Details.
This opens up the detailed configuration page for the cache. Go to the Advanced Settings tab and click on Cache Loader / Refresher in the left bar.
Check the Enable Cache Loader and Refresher checkbox to enable other configuration options.
Configure Cache Loader
For Java, before deploying your JAR files, you need to make sure that:
- You have JDK 11 installed
- Your Environment Variable for Java is set
- Click on the Browse button against Assembly Name to select the assembly
Name of the selected assembly will appear in Assembly Name and any classes implementing interface will be listed down in Class Name list box.
Select the required class.
You can also add the parameters for your cache loader implementation, if required. Provide the Parameter name and Value and click on + to add the parameters. These will be displayed in the box with option to remove the parameter.
Specifying parameters is optional. It is only required if your implementation
ICacheLoader requires parameter(s) during initialization.
- You can add Datasets to your loader implementation as well. A Dataset is a way for you to group similar data so it can be loaded together. This also makes refreshing the data easier. Under the Datasets section, click on the Add Dataset button. This will take you to the following screen where you need to give your dataset a meaningful name.
- Click on OK and Save Changes to save your cache loader's configuration.
Configure Cache Refresher
To configure Cache Refresher, you need to provide Datasets to your implementation. A dataset is a way for you to group similar data so it can be refreshed together at a specific time interval or after a specific event.
- Under the Datasets section, click on the Add Dataset button. This will take you to the following screen.
Enter a meaningful dataset name in the Dataset Name textbox.
Refreshing this dataset is optional. But if you do plan on using Cache Refresher to refresh dataset loaded in the cache after a specific time interval, then you need to enable check the Refresh this dataset at the following schedule checkbox.
You have the following four refresh scheduling options available to you:
- Interval: Interval-based scheduling allows you to specify a recurring time period after which you want the Loader service to refresh your dataset. This option takes value in minutes which are counted after cache starts.
- Daily: Daily scheduling option allows you to specify the exact time of the day at which you want the Loader service to refresh your dataset. This option provides you with a time chart, making it easier for you to choose the time. The time specified will be the local time of your coordinator node.
- Weekly: Weekly option allows you to specify the time as well as days of a week on which you want the Loader service to refresh your dataset. You can choose the time from the time chart and select the days from the list on NCache Web Manager.
- Monthly: Monthly scheduling of Cache Refresher allows you to specify the time stamp, as well as the days of a month on which you want the Loader service to refresh your loaded dataset.
You have the following two ways of selecting the days:
- You can either specify the exact day of the month (as in number) OR
- You can select weeks and their respective days.
Select the refresh schedule of your preference and click on the OK button to add the custom dataset to your Loader/Refresher implementation.
- Repeat the same process if you want to add more than one datasets.
- To edit or remove a dataset, click on the Actions button against the dataset to perform the desired operation.
Under the Options section, you have multiple configurable options to customize the Cache Refresher usage.
Refresh Interval: This is the interval after which the dedicated thread checks the cache for any datasets to refresh. By default, the refresh interval is set to 15 minutes. Specify the time (in minutes) of the refresh interval in the Refresh-Interval box.
Number of Retries: This is the number of times a failed operation is retried. By default, number of retries for a failed operation are 0. You can specify if you want NCache to perform any failed operation again before proceeding to the next operation.Specify this number in the No. of Retries box.
Retry Interval: This is the interval after which the time to wait before trying to execute a failed operation. By default, the retry interval is set to 0 seconds but you can configure it by adding a value in the Retry-Interval box.
Poll-Based Refresh Interval: You can also implement your own method to trigger poll-based dataset refreshing. This is your custom implementation that is triggered after every Refresh Interval and returns a list of datasets that should either be refreshed immediately or within 24 hours. To enable this poll-based refreshing, check the Poll for dataset names to refresh at every refresh interval checkbox.
Once the configurations have been made, click on Deploy Cache Loader to copy the cache loader and refresher assemblies to all nodes.
Click on Save Changes to apply this configuration to the cache.
Add Startup Loader
Add-StartupLoader cmdlet enables the users to configure startup loader and refresher provider for the cache which loads the configured datasets from data source to the cache whenever the cache starts.
The following command adds Loader as Cache Startup Loader on demoClusteredCache.
Add-StartupLoader -CacheName demoClusteredCache -AssemblyPath F:\CacheLoader\Loader.dll -Class CacheLoader.Loader
Add Loader Dataset
Add-LoaderDataset cmdlet enables the users to add datasets to a cache with cache loader and cache refresher configured.
The following cmdlet adds a dataset named product which is loaded into the cache named demoClusteredCache on cache startup and refreshes daily at 5:30 pm:
Add-LoaderDataset -CacheName demoClusteredCache -Dataset "product" -ScheduleOption DailyTime -ScheduleExpression "0:00:17:30"
Remove Startup Loader
Remove-StartupLoader cmdlet enables the users to remove pre-configured loader and refresher from the specified cache.
The following command removes deployed startup loader/refresher from the cache named demoClusteredCache using the default port.
Remove-StartupLoader –CacheName demoClusteredCache