Data Source Providers (Backing Source) for Cache
Note
This feature is only available in NCache Enterprise Edition.
The main purpose of caching is to cache data for achieving maximum performance. While working with cache, client applications may need to perform operations on the data source. For this purpose, NCache supports transparent read/write operations on the data source through Read-Through and Write-Through/Write-Behind caching. Using this feature, client applications can read or write data to the data source through the cache, if needed.
Read-Through and Write-Through caching facilitates the user in the following cases:
- User needs to fetch data from the data source in case it is not present in cache store (Read-Through).
- User needs to update data in data source synchronously after updating cache store (Write-Through).
- User needs to update data in data source asynchronously after updating cache store (Write-Behind).
Using this feature in NCache has the following advantages:
- NCache provides pluggable architecture for Read-Through and Write-Through caching, so the client application code does not need to contain data source logic.
- The data source may change at any time, so this pluggable architecture can configure different data source, while keeping the application code intact.
- Your application only needs to communicate with NCache and NCache will take care of any backend communication with the data source.
To use Read-Through or Write-Through caching, the IReadThruProvider
or the
IWriteThruProvider
interface needs to be implemented. Runtime parameters can also
be provided to the Read-Through/Write-Through provider while configuring it through the
NCache Manager or PowerShell. These parameters will be passed to the Read-Through/Write-Through provider on its
initialization. These initialization parameters can be used in many ways, e.g.
connection string of a data source can be specified as a parameter eliminating
the need to hardcode it in the provider code.
In NCache, the Read-Through/Write-Through providers are configured by name and provider specific API can be used by using the provider name. In case of multiple providers, one of the providers will be configured by default. This default provider will be called if a provider name is not mentioned explicitly through the API. Providers other than the default can be used by utilizing provider specific overloads of the given API.
In This Section
Read-Through Caching
Explains how to read data from the data source in NCache.
Write-Through Caching
Explains how to write data to the data source in NCache.