Try Playground
Show / Hide Table of Contents

Read-through/Write-through and Write-behind for Cache

Client applications may need to perform operations on the data source when working with cache. To support this, NCache provides transparent read and write operations on the data source through Read-through and Write-through/Write-behind caching. This feature enables client applications to read from or write to the data source via the cache when required.

If your provider code is .NET-based, it will be executed in the same process where your cache is running. But, for Java-based provider, the NCache Execution Service will be responsible for code execution.

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

  1. The user needs to fetch data from the data source in case it is not present in the cache store (Read-through).
  2. The user needs to update data in the data source synchronously after updating the cache store (Write-through).
  3. The user needs to update data in the data source asynchronously after updating the 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 sources 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 Management Center or Command Line Tools. 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., the 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.

In This Article
  • In This Section

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top