Package: django-pylibmc
This package provides a memcached cache backend for Django usingpylibmc.  You want to use pylibmc because
it’s fast.Do you need django-pylibmc?Django has direct support for pylibmc.  To use it, set you cache backend:CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1.11211',
    }
}See theDjango documentationfor details about using this cache backend.Two reasons to use django-pylibmc instead are:You need to use the binary protocolYou need to use a username and password to access the memcached server (such as
withMemcachier on Heroku).Requirementsdjango-pylibmc requires pylibmc 1.4.1 or above.  It supports Django 1.7 through
1.9, and Python versions 2.7, 3.4, and 3.5.InstallationGet it frompypi:pip install django-pylibmcorgithub:pip install -e git://github.com/django-pylibmc/django-pylibmc.git#egg=django-pylibmcUsageYour cache backend should look something like this:CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': 'localhost:11211',
        'TIMEOUT': 500,
        'BINARY': True,
        'OPTIONS': {  # Maps to pylibmc "behaviors"
            'tcp_nodelay': True,
            'ketama': True
        }
    }
}To use amemcached local socket connection,
setLOCATIONto the path to the file, i.e.'/var/run/memcached/memcached.sock'.If you want to use the memcached binary protocol, set theBINARYkey’s
value toTrueas shown above.BINARYisFalseby default.If you want to controlpylibmc behaviors, use theOPTIONS.OPTIONSis an empty dict by default.Pylibmc supportscompressionand the
minimum size (in bytes) of values to compress can be set via the Django
settingPYLIBMC_MIN_COMPRESS_LEN.  The default is0, which is disabled.Pylibmc 1.3.0 and above allows to configure compression level, which can
be set via the Django settingPYLIBMC_COMPRESS_LEVEL. It accepts the
same values as the Pythonzlibmodule. Please note that pylibmc changed the default from1(Z_BEST_SPEED)
to-1(Z_DEFAULT_COMPRESSION) in 1.3.0.Configuration with Environment VariablesOptionally, the memcached connection can be configured with environment
variables (on platforms like Heroku). To do so, declare the following
variables:MEMCACHE_SERVERSMEMCACHE_USERNAMEMEMCACHE_PASSWORDCaching TimoutsWhen setting a cache value, memcache allows you to set an expiration for the
value. Commonly, the value is set to a timeout in seconds. However, other
values are allowed including Unix timestamps and 0 for “never expire”. The
highest number of seconds is 30 days - more than that, and the value is
treated like a timestamp.Django instead tries to work with cache timeouts in seconds after the current
time. 0 is treated as 0 seconds, meaning the item should expire immediately.
A timeout of None signals that the item should not expire. There is some
support for memcache-style Unix timestamps as well.In the distant past (Django 1.3?), a timeout of 0 was converted to the default
timeout.The current django-pylibmc behaviour is to pass 0 to the backend, which should
be interpreted as “never expire”. Omiting the timeout will get the Django
default.In the future, django-pylibmc will adopt the latest Django behaviour.
The safest solution for your own code is to omit the timeout parameter (and
get the default timeout), or set it to a timeout in seconds (less than 30
days). This way, your code will work when the Django behaviour is adopted.
Avoid using a timeout of 0, None, or a negative number.TestingInstalltox:pip install toxRun the tests like this:toxChangelog0.6.1 - 2015-12-28Supports Django 1.7 through 1.9Supports Python 2.7, 3.4, and 3.50.6.0 - 2015-04-01Requires pylibmc 1.4.1 or greaterSupports Django 1.4 through 1.8.Supports Python 2.5 through 2.7, and Python 3.3 through 3.4In Django 1.6 and higher, when the timeout is omitted, the default
timeout is used, rather than set to “never expire”.