NCache 4.3 - Online Documentation

Member Left Event

 
NOTE: This feature is not available in NCache Express and Professional edition.
 
NCache provides the MemberLeftCallback delegate. It defines the signature to use when you write event handlers to respond when a node leaves the cluster.
 
Notify application when a node leaves
 
  1. Add the following namespaces in your application for using events:
     
    using Alachisoft.NCache.Web.Caching;
    using Alachisoft.NCache.Runtime;
     
  2. Create an event handler procedure that will be called by MemberLeftCallback when a node leaves the cache cluster. For example, the following code prints the node information when a node leaves the cache cluster.
     
    public void OnCacheMemberLeft(NodeInfo nodeinfo)
    {
    Console.Writeline("Node Left With IPAddress" +
    nodeinfo.IPAddress.ToString() +
    "and port number:" + nodeinfo.Port);
    }
     
    Note: The parameter of type NodeInfo is defined in namespace Alachisoft.NCache.Web.Net. It returns the IPAddress and Port number of the leaving node.
     
  3. Create an instance of the MemberLeftCallback delegate that calls the event handler. The following code calls the method created in step two.
     
    Cache _cache = NCache.InitializeCache("myCache");
    _cache.MemberLeft = new MemberLeftCallback(this.OnCacheMemberLeft);
     
    When a node leaves the cache cluster, the OnCacheMemberLeft method is called.
 
See Also
 
© Copyright  2014 Alachisoft. All rights reserved.