summaryrefslogtreecommitdiff
path: root/django/core/cache/backends/memcached.py
diff options
context:
space:
mode:
authorCurtis Maloney <curtis@tinbrain.net>2013-10-19 09:49:24 +1100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-11-23 15:06:59 +0100
commitffc37e2343a93cf6d44247e20cd263b41f931716 (patch)
treece16f3cc212271f3a4d9f02d25c87b770f09955e /django/core/cache/backends/memcached.py
parent3ca0815c0b4ddf7dd1fe74839e2c3e8633c3ea31 (diff)
Fixed #21012 -- New API to access cache backends.
Thanks Curtis Malony and Florian Apolloner. Squashed commit of the following: commit 3380495e93f5e81b80a251b03ddb0a80b17685f5 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Nov 23 14:18:07 2013 +0100 Looked up the template_fragments cache at runtime. commit 905a74f52b24a198f802520ff06290a94dedc687 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Nov 23 14:19:48 2013 +0100 Removed all uses of create_cache. Refactored the cache tests significantly. Made it safe to override the CACHES setting. commit 35e289fe9285feffed3c60657af9279a6a2cfccc Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Nov 23 12:23:57 2013 +0100 Removed create_cache function. commit 8e274f747a1f1c0c0e6c37873e29067f7fa022e8 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Nov 23 12:04:52 2013 +0100 Updated docs to describe a simplified cache backend API. commit ee7eb0f73e6d4699edcf5d357dce715224525cf6 Author: Curtis Maloney <curtis@tinbrain.net> Date: Sat Oct 19 09:49:24 2013 +1100 Fixed #21012 -- Thread-local caches, like databases.
Diffstat (limited to 'django/core/cache/backends/memcached.py')
-rw-r--r--django/core/cache/backends/memcached.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index c49c20e59b..216ceb04e1 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -2,13 +2,13 @@
import time
import pickle
-from threading import local
from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.encoding import force_str
+from django.utils.functional import cached_property
class BaseMemcachedCacheMethods(RenameMethodsBase):
@@ -177,24 +177,14 @@ class PyLibMCCache(BaseMemcachedCache):
"An implementation of a cache binding using pylibmc"
def __init__(self, server, params):
import pylibmc
- self._local = local()
super(PyLibMCCache, self).__init__(server, params,
library=pylibmc,
value_not_found_exception=pylibmc.NotFound)
- @property
+ @cached_property
def _cache(self):
- # PylibMC uses cache options as the 'behaviors' attribute.
- # It also needs to use threadlocals, because some versions of
- # PylibMC don't play well with the GIL.
- client = getattr(self._local, 'client', None)
- if client:
- return client
-
client = self._lib.Client(self._servers)
if self._options:
client.behaviors = self._options
- self._local.client = client
-
return client