Skip to content

Commit

Permalink
Adds pylibmc support.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Dec 8, 2014
1 parent 13ea4b0 commit 47bb01c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
16 changes: 10 additions & 6 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ Requirements

- Django 1.6 or 1.7
- Python 2.6, 2.7, 3.2, 3.3, or 3.4
- `django-redis <https://github.com/niwibe/django-redis>`_,
`memcached <https://docs.djangoproject.com/en/1.7/topics/cache/#memcached>`_,
`filebased <https://docs.djangoproject.com/en/1.7/topics/cache/#filesystem-caching>`_
(only with Django >= 1.7 as it is not thread-safe before),
or `locmem <https://docs.djangoproject.com/en/1.7/topics/cache/#local-memory-caching>`_
(but it’s not shared between processes, so don’t use it with RQ or Celery)
- a cache configured as `default` with one of these backends:

- `django-redis <https://github.com/niwibe/django-redis>`_
- `memcached <https://docs.djangoproject.com/en/1.7/topics/cache/#memcached>`_
(using either python-memcached or pylibmc)
- `filebased <https://docs.djangoproject.com/en/1.7/topics/cache/#filesystem-caching>`_
(only with Django >= 1.7 as it was not thread-safe before)
- `locmem <https://docs.djangoproject.com/en/1.7/topics/cache/#local-memory-caching>`_
(but it’s not shared between processes, so don’t use it with RQ or Celery)

- PostgreSQL, MySQL or SQLite

Usage
Expand Down
1 change: 1 addition & 0 deletions runtests_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ psycopg2
MySQL-python
django-redis
python-memcached
pylibmc
South
11 changes: 10 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
},
'pylibmc': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}

CACHES['default'] = CACHES.pop(os.environ.get('CACHE_BACKEND', 'locmem'))
DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'locmem')
CACHES['default'] = CACHES.pop(DEFAULT_CACHE_ALIAS)
if DEFAULT_CACHE_ALIAS == 'memcached':
del CACHES['pylibmc']
elif DEFAULT_CACHE_ALIAS == 'pylibmc':
del CACHES['memcached']


INSTALLED_APPS = [
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
envlist =
py2.6-django1.6-{sqlite3,postgresql,mysql}-{locmem,redis,memcached},
py2.6-django1.6-{sqlite3,postgresql,mysql}-{locmem,redis,memcached,pylibmc},
py2.7-django{1.6,1.7}-{sqlite3,postgresql,mysql}-pylibmc,
py{2.7,3.2,3.3,3.4}-django1.7-{sqlite3,postgresql,mysql}-filebased,
py{2.7,3.2,3.3,3.4}-django{1.6,1.7}-{sqlite3,postgresql,mysql}-{locmem,redis,memcached},

Expand All @@ -21,6 +22,7 @@ deps =
py2.6: unittest2
py{2.6,2.7}: MySQL-python
py{2.6,2.7}: python-memcached
py{2.6,2.7}: pylibmc
py{3.2,3.3,3.4}: https://github.com/clelland/MySQL-for-Python-3/tarball/master
py{3.2,3.3,3.4}: python3-memcached
setenv =
Expand All @@ -31,5 +33,6 @@ setenv =
filebased: CACHE_BACKEND=filebased
redis: CACHE_BACKEND=redis
memcached: CACHE_BACKEND=memcached
pylibmc: CACHE_BACKEND=pylibmc
commands =
coverage run -a --source=cachalot ./runtests.py

0 comments on commit 47bb01c

Please sign in to comment.