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.
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\
See Also