Cache Startup Loader and Refresher Components
Note
This feature is only available in NCache Enterprise Edition.
ICacheLoader Interface
To configure Cache Startup Loader and Refresher, ICacheLoader interface needs to be implemented and then configured using NCache Web Manager or PowerShell tool. NCache uses this custom provider to load and refresh data from the configured data source.
Important
Make sure that the NCache Loader Service is running and the firewall is disabled.
The class implementing this interface allows NCache to load data from the master data source to the cache. Therefore, this class needs to implement the logic for loading the required data from your data source. The following methods are required to be defined by the classes implementing loader and refresher:
Member | Type | Description |
---|---|---|
Init |
void |
This method is called by NCache on startup, and takes as input an IDictionary/Map of parameters which can be passed while configuring cache loader/refresher. Please refer to Configure Cache Startup Loader and Refresher in Administrators' Guide to understand how to configure cache loader/refresher in NCache. Through the input param, you can specify runtime parameters to your deployed provider like connection string etc. |
LoadDatasetOnStartup |
object |
LoadDatasetOnStartup contains the logic to load data from the master data source and returns a user context object. This method takes string dataset that includes the data to be loaded in the cache. This data is then loaded in the cache and the UserContext can be used to track loaded data. |
RefreshDataset |
object |
RefreshDataset contains the logic to refresh data that has been loaded in the cache. This method takes the UserContext returned by LoadDatasetOnStartup to understand which data it needs to refresh. When invoked, this method fetches fresh data from the data source based on the user context it receives. |
GetDatasetToRefresh |
Dictionary |
GetDatasetToRefresh takes user context and iterates over it to assign RefreshPreference to each item in the dataset. It returns a Dictionary containing data to refresh with respective refresh interval. |
cache-loader tag
Note that the datasets are specified through NCache Web Manager as explained in
Administrators’ Guide. NCache adds these datasets under
the <cache-loader>
tag into config.ncconf, which are then fetched in the
client application.
<cache-loader retries="0" retry-interval="0" enabled="True" refresh-on-event="False" refresh-interval="15">
<provider assembly-name="Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" class-name="Loader.Loader" full-name="Loader.dll"/>
<parameters name="connString" value="abc"/>
<datasets>
<dataset name="products" schedule-expression="0:1,5:12:00" schedule-option="Weekly"/>
<dataset name="orders" schedule-expression="0:00:00:20" schedule-option="DailyInterval"/>
<dataset name="customers" schedule-expression="0:00:00:00" schedule-option="DailyTime"/>
<dataset name="stock" schedule-expression="0:1,15,L:10:00" schedule-option="Monthly"/>
<dataset name="discount" schedule-expression="1,L:5,6:09:52" schedule-option="Monthly"/>
<dataset name="sale" schedule-expression="" schedule-option=""/>
</datasets>
</cache-loader>
Properties | Description |
---|---|
retries |
Number of retries to perform any failed operation before the next operation. |
retry-interval |
The time interval between each retry attempt to perform the failed operation. |
enabled |
Determines whether /refresher is enabled or not. |
refresh-on-event |
Determines whether to enable/disable poll-based refreshing. |
refresh-interval |
The time interval after which the refresh thread is invoked to fetch data to be refreshed. |
assembly-name |
Human-understandable name of the deployed cache loader assembly. |
class-name |
Name of class implementing the ICacheLoader interface. |
full-name |
Name of assembly to be deployed. |
name |
Under parameters is the name of the added parameter. |
value |
Under parameters is the value of the added parameter. |
name |
Under dataset is the name of the added dataset. |
schedule-expression |
Refresh schedule expression of the dataset. |
schedule-option |
Refresh schedule option of the added dataset. |
See Also
Cache Startup Loader and Refresher Overview
Implementation of Cache Loader and Refresher
Data Source Providers (Backing Source)
Custom Cache Dependencies