Alachisoft NCache 4.1 - Online Documentation

Enabling Read-through Cache Provider

 
NOTE: This feature is not available in NCache Express and Professional edition.
 
To enable Read-through caching, you need to implement IReadThruProvider and specify them in the cache properties. NCache Manager provides an interface for specifying them in the cache properties. For enabling read-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 read-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. Check the Enable Read-Through on this cache check box.
  6. Click Add button and browse the Assembly that contains the class implementing IReadThruProvider and then select class name from the list. The Assembly implementing IReadThruProvider must contain the reference of Alachisoft.NCache.Runtime.dll.
  7. Deploy appropriate assemblies to the cache servers using Deploy Provider button from same tab view.
  8. You can provide some additional parameters (like datasource file name) if required from the same screen.
  9. Add following namespaces in your project:
     
    using Alachisoft.NCache.Web.Caching;
    using Alachisoft.NCache.Runtime.DatasourceProviders;
    using Alachisoft.NCache.Runtime;
     
  10. Now you can make direct calls to NCache to get the required items. If NCache does not have already loaded items, then it will use "LoadFromSource" method in specified data access class to load the items from a datasource. The code to access the cache should look like;
     
    Cache mycache = NCache.InitializeCache("myreplicatedcache");
    object product = mycache.Get("Customer:David:1001", "XmlReadThruProvider" , DSReadOption.ReadThru);
     
    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 = "20.200.20.5">
    </cache>
     
    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.