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 and refresh 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 an IDictionary/Map of parameters as input which can be passed while configuring cache loader/refresher. Through the input parameters, 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 an object. This method takes string dataset that includes the data to be loaded in the cache. |
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 dataset. It returns a dictionary containing dataset to refresh with respective refresh preference. |
Dispose |
void |
Dispose method frees up resources by disposing the loader/refresher. |
cache-loader tag
NCache adds the configured datasets under
the <cache-loader>
tag into config.ncconf, which are then fetched in the
client application.
Note
These datasets are specified through NCache Web Manager as explained in Configure Cache Startup Loader.
<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 | Format |
---|---|---|
retries |
Number of retries to perform any failed operation before the next operation. Default value is 0. | - |
retry-interval |
The time interval between each retry attempt to perform the failed operation. Default value is 0 seconds. | - |
enabled |
Determines whether refresher is enabled or not. Default value is False. | True/False |
refresh-on-event |
Determines whether to enable/disable poll-based refreshing. Default value is False. | True/False |
refresh-interval |
The time interval after which the refresh thread is invoked to fetch data to be refreshed. Default value is 15 minutes. | - |
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. This is a unique string . |
- |
schedule-expression |
Refresh schedule expression of the dataset. This expression can either be for minutes, hours, days, weeks, or months. |
|
schedule-option |
Refresh schedule option of the added dataset. | DailyInterval / DailyTime / Weekly / Monthly |
See Also
Cache Startup Loader and Refresher Overview
Implementation of Cache Loader and Refresher
Data Source Providers (Backing Source)
Custom Cache Dependencies