我对ServiceStack.CacheAccess.Memcached.MemcachedClientCache.有意见Increment方法不像预期的那样工作。
在测试中,我使用了一个常规控制台应用程序和ICacheClient接口。
根据方法文档:
在更改该项之前,必须将其插入缓存。 必须以
System.String的形式插入该项。 该操作仅适用于System.UInt32values,所以SO-1始终表示没有找到该项。
所以我们开始:
ICacheClient client = new MemcachedClientCache();
string key = "test";
bool result = client.Remove(key);
Console.WriteLine("{0} removed: {1}", key, result);
//The item must be inserted as a System.String.
result = client.Add(key, "1");
Console.WriteLine("added {0}", result);
long v = client.Increment(key, 1);
Console.WriteLine("first increment : {0}", v);
string o = client.Get<string>(key);
Console.WriteLine("first read: {0}", o);
v = client.Increment(key, 1);
Console.WriteLine("second increment: {0}", v);
o = client.Get<string>(key);
Console.WriteLine("second read: {0}", o);结果:
如您所见,增量不起作用。
enyim的配置:
<enyim.com>
<memcached protocol="Binary">
<servers>
<!-- make sure you use the same ordering of nodes in every configuration you have -->
<add address="memcached-dev1"
port="11211" />
</servers>
<socketPool minPoolSize="10"
maxPoolSize="100"
connectionTimeout="00:00:10"
deadTimeout="00:02:00" />
</memcached>
</enyim.com>我漏掉了什么吗?
发布于 2013-08-31 21:56:14
您不能以这种方式读取计数器的值,因此在Enyim项目(这里)的一个封闭问题中解释了原因。相反,只需将计数器增加0。
var v = cacheClient.Increment(key, 0);https://stackoverflow.com/questions/13142056
复制相似问题