如何确定 Enyim memcache 在存储项目时返回 false 的原因?

发布于 2024-12-12 02:56:02 字数 200 浏览 0 评论 0原文

我如何确定为什么 Enyim 从以下调用中返回 false:

cache.Store(Enyim.Caching.Memcached.StoreMode.Set, key, value);

其他项目存储得很好,因此与服务器的连接似乎不是问题。该对象似乎不大于 1 MB。

那么如何确定导致错误的原因呢?

How can I determine WHY Enyim returned false from the following call:

cache.Store(Enyim.Caching.Memcached.StoreMode.Set, key, value);

Other items are getting stored fine, so it doesn't seem to be an issue with a connection to the server. The object does not appear to be greater than 1 MB.

So how can I determine what is causing the false?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

偷得浮生 2024-12-19 02:56:02

另一件需要检查的事情是您存储的整个对象图是[可序列化的]。如果不是,那么 Enyim 将抛出序列化异常,这将告诉您哪种类型需要标记为可序列化。按照 https://github.com/enyim/EnyimMemcached/wiki/Configure-Logging 中的说明进行操作 启用日志记录。

One other thing to check is that the whole object graph you're storing is [Serializable]. If it isn't then Enyim will throw a serialization exception, which will tell you which type needs to be marked as serializable. Follow the instructions at https://github.com/enyim/EnyimMemcached/wiki/Configure-Logging to enable logging.

撕心裂肺的伤痛 2024-12-19 02:56:02

一种可能性是您的密钥可能包含非法字符。通常,非常低端的 ASCII 字符可能会导致这种情况——我相信 0x30 及以上字符肯定是安全的,而且可能 0x20 及更高字符也可能是安全的。参考 ASCII 字符图表,您可以看到 0x00 到 0x1F 大部分都是特殊字符。 0x20 到 0x2F 是“普通”字符,但在一些参考材料中我看到提到它们也可以用作控制字符。

这个问题给我带来了一些问题;我通过构建一个高度唯一的密钥来解决这个问题,很少考虑长度,然后生成密钥的 MD5 校验和。 MD5 和保证了密钥冲突的风险最小、字符安全以及比实际密钥更短的长度。

One possibility is that your key may include illegal characters. Typically the very low-end of the ASCII characters can cause this--I believe 0x30 and above are certainly safe, and possibly 0x20 and higher as well. Refencing an ASCII character chart you can see 0x00 through 0x1F are largely special characters. 0x20 thru 0x2F are "normal" characters, but in some reference material I've seen mention that they may be used as control characters as well.

This issue caused me some problems; I've solved it by building a highly-unique key, with little regard for length, then generating an MD5 checksum of the key. The MD5 sum guarantees a minimal risk of key-collision, safe characters, and a shorter length than the actual key.

久随 2024-12-19 02:56:02

默认情况下,Memcached 将对象的大小限制为 1MB 以下。检查您的 memcached 服务器上的配置。该限制是可配置的,但不建议更改,因为它会影响服务器本身的整体性能。

Memcached limits the size of objects by default to under 1MB. Check the configuration on your memcached sever. The limit is configurable, but not recommended to be changed as it will affect overall performance of the server itself.

风透绣罗衣 2024-12-19 02:56:02

我们完全包装了 Enyim 客户端,以创建执行正确连接池的静态方法。我们还在包装器代码中做了两件事:

1) 检查密钥是否 <= 250 个字符并且包含有效字符
2) 检查长度是否< 1MB。我们检查字符串和字节[]的长度。

我们还提出了增强请求。
它是: http://www.couchbase.org/issues/browse/NCBC-10< /a>

We totally wrapped the Enyim client to make static methods that did the right connection pooling. We also did two things in our wrapper code:

1) Check that the key is <= 250 characters and contains valid characters
2) Check that the length is < 1mb. We check the length on strings and on byte[].

We also requested an enhancement request.
It is: http://www.couchbase.org/issues/browse/NCBC-10

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文