Read-Through Caching
NCache uses your custom Read-Through provider to communicate with the data source. In Read-Through Caching, NCache will call your provider to load data behind the get call, in case of a cache miss. In clustered caches, where multiple servers are involved, the Read-Through provider will be active (initialized) on all cache server nodes, but Read-Through operations will only be performed by the node that receives the get operation according to the topology being used.
Note
This feature is only available in NCache Enterprise.
Just like Read-Through caching, NCache also provides the option of forced Read-Through through which the data is fetched from the data source forcefully, regardless of whether the data is present in the cache or not. This means that data will not be checked in the cache and will be fetched directly from the data source.
Note
NCache provides a performance counter Read-thru/sec
for Read-Through operations.
The Resync mechanism in NCache keeps the data up to date across the cache. There may be a scenario where the user wants to keep the data synced with the data source. In this case, the data will be synced with the data source whenever an item with resync enabled expires. This way the data in the cache remains fresh and operations are performed on updated data. The NCache Read-Through provider can be used as a resync provider by specifying ResyncOptions
while adding a cache item into the cache. ResyncOptions
takes a flag that indicates whether to resync an item on expiration or not. It takes the Read-Through provider name as a parameter.
Note
The default Read-Through caching provider will be used if the provider name is not specified.
Warning
Do not make calls to the same cache for which Read-Through is configured in the provider code. This can cause recursion and can halt the normal working of the cache.
In This Section
Configure Read-Thru Provider
Explains the IReadThruProvider interface and provides a sample implementation for the interface.
Read-Thru with Cache Operations
Provides samples to use Read-Through with basic and bulk operations in NCache.