NCache 4.3 - Online Documentation

Member Joined Event

 
NOTE: This feature is not available in NCache Express and Professional edition.
 
NCache provides the MemberJoinedCallback delegate. It defines the signature to use when you write event handlers to respond when a new node joins the cluster.
 
Notify application when a node joins
 
  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 MemberJoinedCallback when a node joins the cache cluster. For example, the following code prints the node information that joins the cache cluster.
     
    public void OnCacheMemberJoined(NodeInfo nodeinfo)
    {
    Console.Writeline("Node Joined 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 joined node.
     
  3. Create an instance of the MemberJoinedCallback delegate that calls the event handler. The following code calls the method created in step two.
     
    Cache _cache = NCache.InitializeCache("myCache");
    _cache.MemberJoined = new MemberJoinedCallback(this.OnCacheMemberJoined);
     
    When a new node joins the cache cluster the OnCacheMemberJoined method is called.
 
 
See Also
 
© Copyright  2014 Alachisoft. All rights reserved.