How do I determine why Enyim memcache is returning false when storing an item?

6.1k views Asked by At

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?

4

There are 4 answers

1
STW On

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.

1
jkp On

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.

0
Andrew Csontos On

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

0
elRobbo On

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.