Skip to content

Instantly share code, notes, and snippets.

Created December 7, 2012 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4235931 to your computer and use it in GitHub Desktop.
Save anonymous/4235931 to your computer and use it in GitHub Desktop.
Dummy Node Locator for MemcachedClient
using System.Collections.Generic;
using Enyim.Caching.Memcached;
using log4net;
namespace CacheReplicationAndFailoverTester
{
public class DumbNodeLocator : IMemcachedNodeLocator
{
private static readonly ILog Logger = LogManager.GetLogger(typeof (DumbNodeLocator));
private IList<IMemcachedNode> _nodes;
/// <summary>
/// Always returns the first node in the list
/// </summary>
public DumbNodeLocator()
{
Logger.Debug("Constructor called");
_nodes = new List<IMemcachedNode>();
}
public void Initialize(IList<IMemcachedNode> nodes)
{
Logger.Debug("Initialize called");
_nodes = nodes;
}
public IMemcachedNode Locate(string key)
{
Logger.Debug("Locate called");
return _nodes[0];
}
public IEnumerable<IMemcachedNode> GetWorkingNodes()
{
Logger.Debug("GetWorkingNodes called");
return _nodes;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment