From 0a0708d2d6e34db6abbc5f204ab4c81d9be252a8 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Thu, 29 Oct 2015 23:03:48 +0100 Subject: [PATCH] Use a compat method to wrap the new way of retrieving the cache engine --- imagekit/cachefiles/backends.py | 3 +-- imagekit/utils.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/imagekit/cachefiles/backends.py b/imagekit/cachefiles/backends.py index 5e7025a..e615f2e 100644 --- a/imagekit/cachefiles/backends.py +++ b/imagekit/cachefiles/backends.py @@ -1,7 +1,6 @@ -from ..utils import get_singleton, sanitize_cache_key +from ..utils import get_singleton, get_cache, sanitize_cache_key import warnings from copy import copy -from django.core.cache import get_cache from django.core.exceptions import ImproperlyConfigured diff --git a/imagekit/utils.py b/imagekit/utils.py index 20ecda6..d768f57 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -151,6 +151,16 @@ def call_strategy_method(file, method_name): fn(file) +def get_cache(backend, **kwargs): + try: + from django.core.cache import caches + except ImportError: + from django.core.cache import get_cache + return get_cache(backend, **kwargs) + + return caches[backend] + + def sanitize_cache_key(key): if settings.IMAGEKIT_USE_MEMCACHED_SAFE_CACHE_KEY: # Memcached keys can't contain whitespace or control characters.