NCache 4.6 - Online Documentation

ICacheLoader Interface

 
In order to use ICacheLoader in your application, implement the following interface:
 
void Dispose();
        void Init(IDictionary parameters);
        bool LoadNext(ref OrderedDictionary data, ref object index);
 
Member
Description
Init
 
This method is called by NCache framework on cache startup. This method takes as input a dictionary of parameters which can be passed while configuring Cache Loader through NCache Manager. Please refer to How To Configure Cache Loader section for details. Through this input parameter, runtime parameters for your deployed provider like connection strings can be specified. In this method, tasks such as allocating resources, acquiring connections, etc can be performed. The main concept of this method is to provide user with a starting  point where he/she can initialize the data source settings before loading the data from it.
Dispose
This method is called by NCache framework on cache stop. The purpose of this method is to release resources that may be in use during loading data from data source to the cache. For example, when cache is stopped or LoadNext returns false, then this method can be implemented to close its connection with the data source and dispose all resources in use.
LoadNext
This method is called by NCache framework on cache startup after Init method. This method should contain the logic to load object(s) from the master data source. This method accepts a OrderedDictionary which is to be populated by the data being collected from the data source and an object which indicates the index. Both these parameters are passed by reference. The data loaded in the dictionary would be loaded in the cache and the index can be used to  track the index if data is added in chunks. Please note that this method can contain the logic for returning one item at a time or multiple items in a chunk as it is called iteratively by NCache until it keeps returning false. Index can be used to control the size of the chunks being extracted from the data source. The user needs to make sure that the method returns true when the all the data has been added into the dictionary or else it will form an infinite loop.
 
 
See Also