Skip to content
Newer
Older
100644 68 lines (45 sloc) 1.85 KB
5cec8b9 @jbalogh django-pylibmc is a cache backend using pylibmc
jbalogh authored May 18, 2010
1 ================================
2 pylibmc cache backend for Django
3 ================================
4
5 This package provides a memcached cache backend for Django using
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
6 `pylibmc <http://github.com/lericson/pylibmc>`_. You want to use pylibmc because
5cec8b9 @jbalogh django-pylibmc is a cache backend using pylibmc
jbalogh authored May 18, 2010
7 it's fast.
8
9
10 Requirements
11 ------------
12
5cf5130 @robhudson Refactored to work better with Django 1.3.
robhudson authored Sep 28, 2011
13 django-pylibmc requires Django 1.3. It was written and tested on Python 2.7.
5cec8b9 @jbalogh django-pylibmc is a cache backend using pylibmc
jbalogh authored May 18, 2010
14
15
16 Installation
17 ------------
18
19
20 Get it from `pypi <http://pypi.python.org/pypi/django-pylibmc>`_::
21
22 pip install django-pylibmc
23
24 or `github <http://github.com/jbalogh/django-pylibmc>`_::
25
26 pip install -e git://github.com/jbalogh/django-pylibmc.git#egg=django-pylibmc
27
28
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
29 Usage
30 -----
31
32 Your cache backend should look something like this::
33
5cf5130 @robhudson Refactored to work better with Django 1.3.
robhudson authored Sep 29, 2011
34 CACHES = {
35 'default': {
36 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
37 'LOCATION': 'localhost:11211',
38 'TIMEOUT': 500,
39 'BINARY': True,
40 'OPTIONS': { # Maps to pylibmc "behaviors"
41 'tcp_nodelay': True,
42 'ketama': True
43 }
44 }
45 }
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
46
47
5cf5130 @robhudson Refactored to work better with Django 1.3.
robhudson authored Sep 29, 2011
48 If you want to use the memcached binary protocol, set the `BINARY` key's
49 value to `True` as shown above. `BINARY` is `False` by default.
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
50
51 If you want to control `pylibmc behaviors
5cf5130 @robhudson Refactored to work better with Django 1.3.
robhudson authored Sep 29, 2011
52 <http://sendapatch.se/projects/pylibmc/behaviors.html>`_, use the
53 `OPTIONS`. `OPTIONS` is an empty dict by default.
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
54
5cf5130 @robhudson Refactored to work better with Django 1.3.
robhudson authored Sep 29, 2011
55 Pylibmc supports `compression
56 <http://sendapatch.se/projects/pylibmc/misc.html#compression>`_ and the
57 minimum size (in bytes) of values to compress can be set via the Django
3b36aa2 @robhudson Updated to make compression disabled by default.
robhudson authored Oct 13, 2011
58 setting `PYLIBMC_MIN_COMPRESS_LEN`. The default is 0, which is disabled.
5a3f3c0 @jbalogh better docs
jbalogh authored May 18, 2010
59
60
5cec8b9 @jbalogh django-pylibmc is a cache backend using pylibmc
jbalogh authored May 18, 2010
61 Caveats
62 -------
63
64 This package breaks away from the current handling of ``timeout=0`` in Django.
65 Django converts 0 into the default timeout, while django-pylibmc leaves it as
66 0. memcached takes 0 to mean "infinite timeout." You can still pass ``None``
67 to get the default timeout.
Something went wrong with that request. Please try again.