Read-Through Caching
Note
This feature is only available in NCache Enterprise Edition.
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 which receives get operation according to the topology being used.
Just like Read-Through, NCache also provides the option of forced Read-Through through using which the data is fetched from the data source forcefully, regardless of the data being 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 resync provider by specifying ResyncOptions
while adding a cache item into the cache. ResyncOptions
take a flag that indicates whether to resync item on expiration or not. It takes Read-Through provider name as a parameter.
Note
The default Read-Through provider will be used if 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 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.