Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ A cache is now selected with the following priority:
* If Django is installed, then:
- If the setting is a valid Django cache entry, then use that.
- If the setting is empty use the default cache
* If Werkzeug is installed, then:
* If [cachelib](https://github.com/pallets/cachelib) is installed, then:
- If the setting is a valid Celery Memcache or Redis Backend, then use that.
- If the setting is empty and the default Celery Result Backend is Memcache or Redis, then use that

Expand Down
8 changes: 4 additions & 4 deletions jobtastic/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def get_django_cache(cache):
pass

try:
from werkzeug.contrib.cache import MemcachedCache, RedisCache
CACHES.append('Werkzeug')
from cachelib import MemcachedCache, RedisCache
CACHES.append('cachelib')
except ImportError:
pass

Expand All @@ -34,7 +34,7 @@ def get_cache(app):
Otherwise, if Django is installed, then:
If the setting is a valid Django cache entry, then use that.
If the setting is empty use the default cache
Otherwise, if Werkzeug is installed, then:
Otherwise, if cachelib is installed, then:
If the setting is a valid Celery Memcache or Redis Backend, then use
that.
If the setting is empty and the default Celery Result Backend is
Expand All @@ -54,7 +54,7 @@ def get_cache(app):
else:
return WrappedCache(get_django_cache('default'))

if 'Werkzeug' in CACHES:
if 'cachelib' in CACHES:
if jobtastic_cache_setting:
backend, url = get_backend_by_url(jobtastic_cache_setting)
backend = backend(app=app, url=url)
Expand Down
2 changes: 1 addition & 1 deletion jobtastic/cache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def lock(self, lock_name, timeout=900):
# Possibly using old Django-Redis
lock = self.cache.client.lock
except AttributeError:
# Possibly using Werkzeug + Redis
# Possibly using cachelib + Redis
lock = self.cache._client.lock
have_lock = False
lock = lock(lock_name, timeout=timeout)
Expand Down
6 changes: 3 additions & 3 deletions jobtastic/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from django.test import TestCase
from jobtastic.task import JobtasticTask
from werkzeug.contrib.cache import MemcachedCache
from cachelib import MemcachedCache
try:
from django.core.cache import caches
except ImportError:
Expand Down Expand Up @@ -84,9 +84,9 @@ def test_custom_django_cache(self):
self.assertTrue('herd:%s' % self.key in caches['shared'])
self.assertTrue('herd:%s' % self.key not in caches['default'])

@mock.patch('jobtastic.cache.CACHES', ['Werkzeug'])
@mock.patch('jobtastic.cache.CACHES', ['cachelib'])
@mock.patch.object(DummyClient, 'add', add, create=True)
def test_default_werkzeug_cache(self):
def test_default_cachelib_cache(self):
with self.settings(CELERY_ALWAYS_EAGER=False):
app = Celery()
app.config_from_object(settings)
Expand Down
2 changes: 1 addition & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ unittest2
mock
django-picklefield
six
werkzeug
cachelib