Closed sagepe closed 1 year ago
Noting that since this warning was introduced in Python 3.8, we see the following two syntax warnings from python-memcached
:
memcache.py:1303: SyntaxWarning: "is" with a literal. Did you mean "=="?
if key is '':
memcache.py:1304: SyntaxWarning: "is" with a literal. Did you mean "=="?
if key_extra_len is 0:
I note that there is a PR with a fix for this, but as python-memcached
doesn't seem to be actively maintained at present it hasn't been merged.
Just to note that there appears to be some instability when using pymemcache
and Django in certain situations: https://code.djangoproject.com/ticket/33092
I did switch to pymemcache
for Labour MapIt but it started generating lots of errors similar to those in the Django ticket. Switching back to python-memcache
got rid of them.
Noting that we had an object too large for cache
error from one of our MapIt instances still using the older MemcachedCache
backend when trying to store an object 1.8M in size. Apparently the default object size is 1M for that backend although it can be changed. According to this old Django ticket, this isn't a problem with at least PyLibMCCache
.
Is switching to PyLibMCCache just as straightforward or is it more complicated?
Probably just as straightforward. pylibmc
is written in C whereas pymemcache
is pure-Python. Nevertheless the pylibmc
wheel installed just fine in a virtualenv on msdev001sova
.
Yes, I think I suggested trying pymemcache
first on the basis that it was pure python and the comparison notes on it's PyPI page, but I don't think any of those are critical to us.
The
MemcachedCache
cache back-end that relies onpython-memcached
is deprecated as-of Django 3.2 and needs to be replaced with eitherPyMemcacheCache
(viapymemcache
) orPyLibMCCache
(viapylibmc
). Also, should we consider adding the necessary bindings dependency tosetup.py
?See the Django documentation on caching with memcached (3.2, 4.0). Do we want to consider alternatives to memcache, such as Redis which was added in 4.0?