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 user in the following cases:
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, IReadThruProvider or IWriteThruProvider interfaces need to be implemented respectively and deploy it through NCacheManager.
Runtime parameters can also be provided to provider while configuring it through NCManager. 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-though 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.
See Also