Alachisoft NCache 4.1 - Online Documentation

Enabling Write-through Cache Provider

To enable Write-through caching, you need to implement WriteThruProvider 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 and browse the Assembly that contains the class implementing WriteThruProvider and then select class name from the list. The Assembly implementing WriteThruProvider must contain the reference of NCRuntime.jar.
  7. For enabling the Write-Behind caching, mark the checkbox under Write-Behind column.
  8. Deploy appropriate assemblies to the cache servers using the Deploy Provider button on a same tab view.
  9. You can provide some additional parameters (like datasource file name) if required from the same screen.
  10. Add the following import statement in your project:
    import com.alachisoft.ncache.runtime.datasourceprovider.WriteThruProvider;
  11. The code to add data in a cache should look like:
Cache cache = 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 = "XmlReadThruProvider"
default-writethru-provider = "XmlWriteThruProvider">
<server name = "">
NCache logs the warnings in Application event log in case of an exception during loading the assemblies.
See Also
Copyright © 2005-2012 Alachisoft. All rights reserved.