diff --git a/README.md b/README.md index d57320d..c8446a8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/jobtastic/cache/__init__.py b/jobtastic/cache/__init__.py index a9ef7e7..786b6cd 100644 --- a/jobtastic/cache/__init__.py +++ b/jobtastic/cache/__init__.py @@ -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 @@ -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 @@ -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) diff --git a/jobtastic/cache/base.py b/jobtastic/cache/base.py index 32e0e60..ad3403c 100644 --- a/jobtastic/cache/base.py +++ b/jobtastic/cache/base.py @@ -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) diff --git a/jobtastic/tests/test_settings.py b/jobtastic/tests/test_settings.py index 5869c3a..43dff4a 100644 --- a/jobtastic/tests/test_settings.py +++ b/jobtastic/tests/test_settings.py @@ -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: @@ -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) diff --git a/requirements/tests.txt b/requirements/tests.txt index b710591..2008b28 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -3,4 +3,4 @@ unittest2 mock django-picklefield six -werkzeug +cachelib