Enyim Memcached 客户端无法在传递过期参数的情况下工作
当使用 Enyim memcached 客户端存储具有过期时间跨度的数据时,我发现它不起作用。 有人可以帮忙吗?
在我的测试代码中,我存储了 10 分钟过期时间的日期,我尝试立即从缓存中获取它,但得到了一个 null 对象。
Enyim.Caching.MemcachedClient client = new Enyim.Caching.MemcachedClient();
client.Store(Enyim.Caching.Memcached.StoreMode.Set, "one", 1, new TimeSpan(0, 10, 0));
object obj;
client.TryGet("one", out obj); // obj == null
Assert.AreNotEqual(null, obj); // this will fail
when using Enyim memcached client to store data with a expire timespan, i find that it doesn't work.
Could anyone help?
In my test code, I store the date with 10 minutes expiration time, and i try to get it from cache immediately but got a null object.
Enyim.Caching.MemcachedClient client = new Enyim.Caching.MemcachedClient();
client.Store(Enyim.Caching.Memcached.StoreMode.Set, "one", 1, new TimeSpan(0, 10, 0));
object obj;
client.TryGet("one", out obj); // obj == null
Assert.AreNotEqual(null, obj); // this will fail
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我不确定您的示例是否含糊,或者您是否确实使用对象类型,但我在使用自定义对象时遇到了同样的问题。整数、字符串等都可以正常工作,但是一旦我将自定义对象放入缓存中,它就始终为 NULL。事实证明我的对象没有可序列化属性。一旦我把它放在那里,一切都会按预期进行。
I'm not sure if you're being vague w/ your example or if you really are using an object type but I had the same problem using custom objects. Integers, strings, etc. would work fine but my custom object was always NULL as soon as I put it in the cache. Turns out I didn't have the Serializable attribute on my object. Once I put that on there everything worked as expected.
Hyacinthus 对他的问题非常精确,答案有些无关紧要。仅当设置过期时间(时间跨度或日期时间)时,我才会遇到同样的问题。
Enyim 的 github 上也有一个问题 https://github.com/enyim/EnyimMemcached/issues /110
我们公司的代码库中有一个调整后的版本,但它已经过时了。当我有时间时,我会尝试找到修复程序并返回此问题,并向 Enyim 发送拉取请求。
编辑:
我还在 github 上找到了这个。
想要检查您正在使用的服务器版本吗?
我最初的评论仍然有效,因为我使用两个不同的 dll 运行测试,调整后的一个可以工作,而 CouchBase 附带的那个则失败
Hyacinthus is pretty precise on his question, the answers are somewhat irrelevant. I am having the same problem ONLY when setting an expiration, either as a Timespan or as a DateTime.
There is also an issue for this at Enyim's github https://github.com/enyim/EnyimMemcached/issues/110
We have a tweaked version at my company's codebase, but it is outdated. I will try to locate the fix and get back to this, and send a pull request to Enyim, when I find the time.
EDIT:
I also found this on github.
Care to check the server version you are using?
My initial comment still stands, as I run tests using the two different dlls, and the tweaked one works while the one shipped with CouchBase fails
请检查您的服务器。
1.使用 MemCacheD Manager
或
2.使用 telnet 127.0.0.1 11211(更改为您的服务器设置)
并输入:stats
它会显示您的统计数据。
查看“时间”项目统计。
这是你必须转换的第二种格式,
简单地你可以与“1262517674”进行比较,
如果小于“1262517674”,则说明你的memcached服务器太旧了。
请升级或更改您的 memcached 版本。
否则只需更改您的 memcached 版本
Please check your server.
1.Use MemCacheD Manager
Or
2.Use telnet 127.0.0.1 11211(change to your sever setting)
and type:stats
It would show your the stats.
See the "time" item stat.
It's second format you must convert it,
Simply you can compare with "1262517674",
If smaller than "1262517674",your memcached server it too old.
Please Upgrade Or change your memcached version.
Otherwise Just change your memcached version
答案是memcached(windows) 1.4.4 64位版本有这个bug。如果它符合您的需要,您可以尝试 1.4.4 32 位 Windows 版本,或者您可以尝试找到另一个 64 位编译版本。这个问题也花了我一整天的时间,我终于安装了“1.4.4 32位版本”和viola,一切都与1.4.4完美配合。 32 位。
The answer is that memcached(windows) 1.4.4 64-bit version has this bug. If it fits your needs you can try 1.4.4 32-bit version for windows, or you can try to find another 64-bit compiled version. This problem also took my whole day and I finally installed "1.4.4 32-bit version" and viola, everything works perfect with 1.4.4. 32-bit.
创建 memcached 客户端对象是一项成本高昂的操作,因此请尝试在应用程序启动时创建它并重用该对象。
这就是我启动 MemcachedClient 对象并使用 Enyim 客户端访问 Membese Build 的方式。
Create a memcached client object is a costly operation, so try to create it on start of the application and reuse that object.
This how I initiate MemcachedClient Object and access Membese Build using Enyim client.
你需要先获得一个歌手。
例如:
you need to get a sington first.
eg: