NCache 4.4 - Online Documentation

Read-Through Provider

 
A requested value not present in the cache can be automatically obtained from the main data source by the cache and provided to the user in such a manner that it seems to the caller that it came from the cache. This is known as Read Through Cache. The gain from it is that the application can depend on the cache for both cached data as well as for transparent data loading instead of adding data loading logic at the point where it requires the data. Read-through caching can be configured using the following methods.
 
Using NCache Manager
 
  • Click on the cache name in Cache Explorer to open cache settings.
  • Go to the Baking Source tab.
  • Check Enable Read-Through on this cache check box to enable it. After enabling it, other options will get enabled as well.
 
 
  • Cllick Add to select assembly that has IReadThruProvider implementation.
  • A new dialog box Add New Provider will open. Enter Provider Name and click on ‘…’ button to browse for assembly implementing IReadThruProvider interface.
 
 
  • Browse for the required assembly and select Open. Name of selected assembly will be appeared in Assembly Name and its classes implementing the interface will be listed down in Class Name list box.
 
 
  • Select the required read-through provider. You can also provide the values to your read-through provider class, if required. Just write the parameter name in Parameter field and its value against it under the Value field. Click OK.
 
 
  • Selected provider class will be listed in Read-Through provider list at Backing Source tab.
 
 
  • Now deploy the read-through provider assembly along with its dependency assemblies, if any. Click on the Deploy Provider button at the left bottom of the Backing Source tab. Browse for required assemblies. Select all the required assemblies and click Open.
 
 
  • Right click the cache in Cache Explorer and select Apply Configuration option.
 
 
 
 
 
Using Command Tool
 
  • Open command prompt
  • Go to the NCache tools directory: cd %NCHOME%/bin/tools
  • Use addbackingsource.exe tool, provide the required information as:
addbackingsource.exe demoLocalCache /path C:\Users\Administrator\Downloads\Providers\Providers.dll/cNCache.Sample.Providers.Readers.Reader1 /pnreader1/R
  • Hit ENTER key, it will configure Reader1 read-through provider on demoLocalcache.
  • Now depoly all of the required assemblies (assembly in which you have implemented the read-through provider and all of its dependency assemblies) using deployprovider.exe. Use following command on command prompt:
deployprovider demoLocalCache /T C:\Users\Administrator\Downloads\Providers\
  • Hit ENTER key, it will deploy all of the assemblies from the given path to NCache deploy folder.
 
See Also