1
var config = new MemcachedClientConfiguration();
config.Protocol = MemcachedProtocol.Binary;
config.AddServer(server[0],int.Parse(server[1]));


var mc = new MemcachedClient(config);

var finish = mc.Store(StoreMode.Set, key, value,TimeSpan.FromSeconds((double)60000));
if(finish)
{
var obj=mc.Get(key);
Debug.Assert(obj==null,"obj is null.")
}

The result(obj) always returns null, why?

If expire is set to TimeSpan.MaxValue it is okay.

dove
  • 20,469
  • 14
  • 82
  • 108
sjbwylbs
  • 151
  • 14
  • there's a duplicate issue here http://stackoverflow.com/questions/6853958/enyim-memcached-client-doesnt-work-with-expiration-parameter-passed/12712640#12712640 – ghallas Oct 03 '12 at 16:30

1 Answers1

0

The code looks fine. I've run a test for this and it passes

     [Test]
     public void Should_get_object()
     {
        const string key = "1";
        const string value = "6";
        var mc = new MemcachedClient();

        var finish = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, 
                              key, value, TimeSpan.FromSeconds((double)60000));

         if(finish)
         {
            var obj=mc.Get(key);
            Assert.That(obj!=null,"obj is null.");
         }
    }

Thus I'd suspect the configuration, here is the one I've used for comparison

<enyim.com>
    <memcached>
      <servers>
        <add address="127.0.0.1" port="11211"/>
      </servers>
      <socketPool minPoolSize="10" maxPoolSize="100" 
                  connectionTimeout="00:00:10" deadTimeout="00:02:00"/>
    </memcached>
  </enyim.com>
dove
  • 20,469
  • 14
  • 82
  • 108