Cache Startup Loader Components
Note
This feature is only available in NCache Enterprise Edition.
ICacheLoader Interface
To configure Cache Startup Loader, ICacheLoader interface needs to be implemented and then configured using NCache Web Manager. NCache uses this custom provider to load data from the configured data source either in bulk or sequentially in case of key dependency among the items. On cache startup, NCache framework iteratively calls the LoadNext() method of this custom provider until no more data remains.
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 this loader:
Member | Type | Description |
---|---|---|
Init |
void |
This method is called by NCache framework on startup, and takes as input an IDictionary of parameters which can be passed while configuring cache loader through NCache Web Manager. Please refer to Configure Cache Startup Loader in Administrators' Guide for further details. Through the input param you can specify runtime parameters to your deployed provider like connection string. |
LoadNext |
LoaderResult |
LoadNext() contains the logic to load object(s) from the master data source and return to an object of the LoaderResult class. This method accepts an object which indicates the state. The data is then loaded in the cache and the state can be used to track loaded data if data is added in chunks. The members of LoaderResult are discussed in detail later in the chapter. |
LoaderResult Class
Member | Type | Description |
---|---|---|
Data |
OrderedDictionary |
An OrderedDictionary which is populated by the data being collected from the data source. Contains methods to Add, Insert, Remove data from the cache. |
HasKeyDependency |
bool |
To check whether the item is dependent on another key or not. If specified true, the data will be added sequentially, and not in bulk. |
HasMoreData |
bool |
To specify whether the loader result has any data remaining else the data is considered as loaded in the cache. |
UserContext |
object |
Object to be used by the user according to requirements, can be used to indicate state. |
cache-loader tag
Note that the hints are specified through NCache Web Manager as explained in
Administrators’ Guide. NCache adds these hints under
the <cache-loader>
tag into config.ncconf, which are then fetched in the
client application.
<cache-loader retries="0" retry-interval="0" enabled-loader="True" hints-enabled="True">
<provider assembly-name="Loader, Version=x.x.x.x, Culture=neutral, PublicKeyToken=null" class-name="Loader.Loader" full-name="Loader.dll"/>
<distribution-hints>
<hint name="Customer"/>
<hint name="Products"/>
<hint name="Order"/>
</distribution-hints>
</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-loader |
Determines whether loader is enabled or not. |
hints-enabled |
Determines whether distribution hints are enabled or not. |
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 |
Name of the hint specified by the user through Manager. |
See Also
Sample Implementation of ICacheLoader on Single Node
Sample Implementation of ICacheLoader with Distribution Hints
Data Source Providers (Backing Source)
Custom Cache Dependencies