• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

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, the client applications can read or write data to the data source through cache, if needed.

Read-Through and Write-Through caching facilitates the user in the following cases:

  1. User needs to fetch data from the data source in case it is not present in cache store (Read-Through).
  2. User needs to update data in data source synchronously after updating cache store (Write-Through).
  3. 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 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 interface needs to be implemented. Runtime parameters can also be provided to the Read-Through/Write-Through provider while configuring it through NCache Web Manager or PowerShell. These parameters will be passed to 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, Read-Through/Write-Through providers are configured by name and provider specific APIs can be used by using provider name. In case of multiple providers, one of the providers 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 be used by utilizing provider specific overloads of the given APIs.

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.

Back to top Copyright © 2017 Alachisoft