NCache 4.3 - Online Documentation

Enabling Write-through Cache Provider

NOTE: This feature is not available in NCache Express and Professional edition.
To enable Write-through caching, you need to implement IWriteThruProvider and specify them in the cache properties. NCache Manager provides an interface for specifying them in the cache properties. For enabling write-through caching, follow the steps given below:
  1. From the start programs, launch NCache Manager.
  2. Open the project containing cache or cluster for which you want to configure the write-through caching.
  3. From the explorer, select the cache or cluster. In the right pane, cluster/cache view will be opened.
  4. From the view, select the Backing Source tab.
  5. For enabling Write-through caching, check the Enable Write-Through on this cache check box on the same tab.
  6. Click Add button, browse the Assembly that contains the class implementing interface IWriteThruProvider and contain the reference of Alachisoft.NCache.Runtime.dll. If assembly contains more than one class select the class name from the list.
  7. By enabling you can specify an operation delay and batch interval, operation delay will specify the time cache suspend each operation write on data source by default its value is 0. Batch interval is a periodic interval for operation expiration (operation delay timeout) by default its value is 5.
  8. You can specify throttling (operation per second) value throttling will determine the rate at which cache writes the update to data source by default its value is 500.
  9. Failed operation queue limit specifies maximum operation count to be re queued in case of database operation failures. Zero specifies failed operations will not be retried by default its value is 5000 and eviction ration evict most retries operations from the retry queue by default its value is 5.    
  10. Deploy appropriate assemblies to the cache servers using Deploy Provider button from same tab view.
  11. You can provide some additional parameters (like data source file name) if required from the same screen.
  12. Add following namespaces in your project:
using Alachisoft.NCache.Web.Caching;
using Alachisoft.NCache.Runtime.DatasourceProviders;
using Alachisoft.NCache.Runtime;
13. The code to add data in a cache should look like:
      Cache mycache = NCache.InitializeCache("myreplicatedcache");
  Product product = new Product();
  CacheItem citem = new CacheItem (product);
  cache.Add(textBox.Text, citem, DSWriteOption.WriteThru, null);
    If you do not want to give provider name in API, you can provide it in client.ncconf. If provider name is not provided in both API and 
    client.ncconf, default provider will automatically be used.
<cache id = "myreplicatedcache" client-cache-id = "" default-readthru-provider = "XmlReadThruProviderclient-cache-syncmode="optimistic" default-writethru-provider = "XmlWriteThruProvider" load-balance="True" server-runtime-context="NCACHE">
<server name = "">
NCache logs the warnings in Application event log in case of an exception during loading the assemblies.
For debuging your providers see How to Debug Providers.
See Also
© Copyright  2014 Alachisoft. All rights reserved.