|Version 2 (modified by 6 years ago) (diff),|
Tickets #12427 and #11675 are opened with different by related goals: get rid of cmemcache (which had gone the way of the broken-as-heck dodo) and add support for a new libmemcached wrapper pylibmc (respectively).
Email thread seen here begins: http://groups.google.com/group/django-developers/browse_thread/thread/4eb685ca5b305f18/
Ticket is put in for 1.2 to put use of cmemcache as FuturePendingDeprecation, while adding support for pylibmc was greenlit for 1.3
Discussion re-started with three key points to debate:
- Pylibmc 1.1 doesn't play that nice with mod_wsgi due to it's use of the Simplified GIL API (see: http://www.dctrwatson.com/2010/09/beware-of-using-pylibmc-1-1-and-mod_wsgi/). Probably just need to make note of it in the documentation, but it's worth noting.
- The suggested use of using query-string for client-specific options and libmemcached 'behaviors' eventually leading to massive client strings, and the use of a CACHE_SETTINGS dictionary may be a better solution.
- Because it bypasses the GIL, pylibmc isn't thread safe. There are a few different solutions, the most apparent being to use pylibmc's ThreadMappedPool. More info here: http://lericson.blogg.se/code/2009/september/draft-sept-20-2009.html and http://blog.sendapatch.se/2009/september/pooling-with-pylibmc-pt-2.html .
Another post of note with regards to multithreading [ala, celery] here: http://www.dctrwatson.com/2010/09/python-thread-safe-does-not-mean-fork-safe/#more-48
Caveats/Notes on the draft: A) This is only the memcache.py file, changes to conf/global_settings and core/cache/base will be needed to handle the move towards CACHE_SETTINGS
B) pylibmc and memcached handle negative timeouts differently. The expected behavior as laid out in template tests is how python-memcached handles it (instant expiration). I had to do a fairly sad looking hack to make pylibmc work, and is noted in a comment.
C) The current version of pylibmc doesn't play nice with python sub-interuptors, and thus, mod_wsgi. There is a commit (https://github.com/lericson/pylibmc/commit/ddd2f011f73d8ccc6347c5471eff378bef58dbd5) in trunk that fixes this, but a release has not been given out. We may want to be extra-communicative of this and the possible workarounds.