Data Source Providers (Backing Source)
The main purpose of a caching solution is to cache the data source as temporary storage. While working with cache, client applications may need to perform operations on master data source. For this purpose, NCache supports transparent read/write operations to any type of back-end data source through Read-Through and Write-Through caching. Using this feature, client application can fetch or write data to master data source if needed. Read-Through and Write-Through caching facilitates the user in the following cases:
- User needs to fetch data from data source in case it is not present in cache store (Read-Through).
- User needs to update data source (any write operation) after updating cache store (Write-Through).
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 be changed 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 backend communication with data source.
To use read- through or Write-Through caching,
IWriteThruProvider interfaces need to be implemented respectively and deploy
it through NCache Manager.
Runtime parameters can also be provided to provider while configuring it through NCache Manager. These parameters will be passed to 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 and there is no need to put it in provider code. Thus, it provides a flexible way to change the data source settings while configuring it without code changes in provider.
In NCache, providers are configured by name and provider specific APIs can be employed by using provider name. NCache also supports multiple Read-Through/Write-Through providers with applications. In case of multiple providers, one of provider will be configured as default one. Default provider will be called if provider name is not mentioned explicitly through API. Providers other than default can also be used by utilizing provider specific overloads of the given APIs.
In This Section
Explains how to read data from the data source in NCache.
Explains how to write data to the data source in NCache.