Fixed #3648 -- Added support for cmemcached Python library. Thanks, floguy@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4827 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9c10a2f118
commit
a5bb14ed2e
|
@ -3,9 +3,12 @@
|
||||||
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
|
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import memcache
|
import cmemcache as memcache
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise InvalidCacheBackendError, "Memcached cache backend requires the 'memcache' library"
|
try:
|
||||||
|
import memcache
|
||||||
|
except:
|
||||||
|
raise InvalidCacheBackendError("Memcached cache backend requires either the 'memcache' or 'cmemcache' library")
|
||||||
|
|
||||||
class CacheClass(BaseCache):
|
class CacheClass(BaseCache):
|
||||||
def __init__(self, server, params):
|
def __init__(self, server, params):
|
||||||
|
|
|
@ -66,10 +66,19 @@ deleting arbitrary data in the cache. All data is stored directly in memory,
|
||||||
so there's no overhead of database or filesystem usage.
|
so there's no overhead of database or filesystem usage.
|
||||||
|
|
||||||
After installing Memcached itself, you'll need to install the Memcached Python
|
After installing Memcached itself, you'll need to install the Memcached Python
|
||||||
bindings. They're in a single Python module, memcache.py, available at
|
bindings. Two versions of this are available. Choose and install *one* of the
|
||||||
ftp://ftp.tummy.com/pub/python-memcached/ . If that URL is no longer valid,
|
following modules:
|
||||||
just go to the Memcached Web site (http://www.danga.com/memcached/) and get the
|
|
||||||
Python bindings from the "Client APIs" section.
|
* The fastest available option is a module called ``cmemcache``, available
|
||||||
|
at http://gijsbert.org/cmemcache/ . (This module is only compatible with
|
||||||
|
the Django development version. Django 0.96 is only compatible with the
|
||||||
|
second option, below.)
|
||||||
|
|
||||||
|
* If you can't install ``cmemcache``, you can install ``python-memcached``,
|
||||||
|
available at ftp://ftp.tummy.com/pub/python-memcached/ . If that URL is
|
||||||
|
no longer valid, just go to the Memcached Web site
|
||||||
|
(http://www.danga.com/memcached/) and get the Python bindings from the
|
||||||
|
"Client APIs" section.
|
||||||
|
|
||||||
To use Memcached with Django, set ``CACHE_BACKEND`` to
|
To use Memcached with Django, set ``CACHE_BACKEND`` to
|
||||||
``memcached://ip:port/``, where ``ip`` is the IP address of the Memcached
|
``memcached://ip:port/``, where ``ip`` is the IP address of the Memcached
|
||||||
|
|
Loading…
Reference in New Issue