Why does Django cache work with locmem but not memcached?

Using Django's cache with locmem (with simple Python classes as values ​​stored in lists / tuples / maps) works fine, but does not work with memcached.

Only part of the keys (despite sufficient allocated memory and long timeouts) penetrate memcached, and none of them has any associated value.

When they are restored, the value will not be returned and they will be deleted from the cache.

The forced value "hi" makes those that appear in the cache can be restored, but does not take into account why most keys are simply missing.

Questions:

  • Why are only some keys ending in memcached while others are not, even if all values ​​are set to hi?
  • Is there a way to enable more logging or error reporting? (everything seems to fail)
  • Why are Python classes being serialized correctly in locmem but not ending in Memcached?
+4
source share
2 answers

Apparently, keys cannot have spaces in them:

http://code.djangoproject.com/ticket/6447
http://blog.pos.thum.us/2009/05/22/memcached-keys-cant-have-spaces-in-them/

As soon as I used the key with a space in it, everything became unpredictable.

+3
source

To find out what is going on, run memcached -vv 2>/tmp/mc_debug_log (I assume you are on some Unixy system) and run it for a short time - you will find the detailed information in this log file made.

Depending on which Python interface is used for memcached, it may be that only strings are supported as values ​​(as in the StringClient module in cmemcache ) or that all collapsible objects (with overhead and tracing, of course), as well as in a more general client module in the same cmemcache, GAE memcache and python-memcached ; if you can use strings as values, maybe you are using an interface of the same type?

+3
source

All Articles