Fixed #32193 -- Deprecated MemcachedCache.

This commit is contained in:
Mariusz Felisiak 2020-12-09 21:27:32 +01:00 committed by GitHub
parent 2c5d6dc447
commit 5ce31d6a71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 40 deletions

View file

@ -77,18 +77,16 @@ database or filesystem usage.
After installing Memcached itself, you'll need to install a Memcached
binding. There are several Python Memcached bindings available; the
three most common are `python-memcached`_, `pylibmc`_, and `pymemcache`_.
two supported by Django are `pylibmc`_ and `pymemcache`_.
.. _`python-memcached`: https://pypi.org/project/python-memcached/
.. _`pylibmc`: https://pypi.org/project/pylibmc/
.. _`pymemcache`: https://pypi.org/project/pymemcache/
To use Memcached with Django:
* Set :setting:`BACKEND <CACHES-BACKEND>` to
``django.core.cache.backends.memcached.MemcachedCache``,
``django.core.cache.backends.memcached.PyLibMCCache``, or
``django.core.cache.backends.memcached.PyMemcacheCache`` (depending on your
``django.core.cache.backends.memcached.PyMemcacheCache`` or
``django.core.cache.backends.memcached.PyLibMCCache`` (depending on your
chosen memcached binding)
* Set :setting:`LOCATION <CACHES-LOCATION>` to ``ip:port`` values,
@ -97,21 +95,21 @@ To use Memcached with Django:
``path`` is the path to a Memcached Unix socket file.
In this example, Memcached is running on localhost (127.0.0.1) port 11211, using
the ``python-memcached`` binding::
the ``pymemcache`` binding::
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': '127.0.0.1:11211',
}
}
In this example, Memcached is available through a local Unix socket file
:file:`/tmp/memcached.sock` using the ``python-memcached`` binding::
:file:`/tmp/memcached.sock` using the ``pymemcache`` binding::
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': 'unix:/tmp/memcached.sock',
}
}
@ -129,7 +127,7 @@ address 172.19.26.240 and 172.19.26.242, both on port 11211::
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': [
'172.19.26.240:11211',
'172.19.26.242:11211',
@ -143,7 +141,7 @@ on the IP addresses 172.19.26.240 (port 11211), 172.19.26.242 (port 11212), and
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': [
'172.19.26.240:11211',
'172.19.26.242:11212',
@ -165,6 +163,12 @@ particularly temporary.
The ``PyMemcacheCache`` backend was added.
.. deprecated:: 3.2
The ``MemcachedCache`` backend is deprecated as ``python-memcached`` has
some problems and seems to be unmaintained. Use ``PyMemcacheCache`` or
``PyLibMCCache`` instead.
.. _database-caching:
Database caching
@ -452,19 +456,6 @@ of 60 seconds, and a maximum capacity of 1000 items::
}
}
Here's an example configuration for a ``python-memcached`` based backend with
an object size limit of 2MB::
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'OPTIONS': {
'server_max_value_length': 1024 * 1024 * 2,
}
}
}
Here's an example configuration for a ``pylibmc`` based backend that enables
the binary protocol, SASL authentication, and the ``ketama`` behavior mode::