1

I'm trying to distribute cache across multiple servers. I have installed Memcached on 2 Linux servers. I'm using .Net Client Libraries to manipulate cache on those servers.

It's always store value on the first server from configuration. I tried to change sequence of the servers and it stores but only on the first in the list.

I use Putty to check if object exist on the server.

The questions are:

How to store object on both servers at the same time?

if I want to verify that this object stored on all servers from configuration file

How I can do it from client libraries?

Here is the example of my code:

static void Main(string[] args)
{ 
     var mc = new MemcachedClient();
     mc.FlushAll();
     mc.Store(StoreMode.Add, "key1", "some information");            
     Console.WriteLine(mc.Get("key1"));
}

and configuration

<enyim.com>
    <memcached>
      <servers>
        <add address="20.23.24.105" port="11211"/>
        <add address="20.23.24.106" port="11211"/>
      </servers>
      <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:10:00" deadTimeout="00:02:00"/>
    </memcached>
  </enyim.com>
Eugene
  • 1,037
  • 2
  • 12
  • 19

1 Answers1

2

I don't think that it is possible to do this with the .NET client because that's not how Memcached is supposed to work. Internally the client will hash each key to only one server. If that server goes down the client will take that into account when hashing future keys. One way around this though would be to do a separate set for each server. This would require you to create two clients, one connected to each server, and send the request twice. If the .NET client provides async sets then you can do this with the latency only being as long as the longest of the two set operations.

mikewied
  • 5,273
  • 1
  • 20
  • 32