Fixed #21012 -- Thread-local caches, like databases. #1972

Closed
wants to merge 5 commits into
from

Projects

None yet

3 participants

@aaugustin
Django member

This continues the work from PR #1782.

@aaugustin aaugustin commented on the diff Nov 23, 2013
django/contrib/sessions/tests.py
@@ -489,6 +489,7 @@ def test_default_cache(self):
},
'sessions': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+ 'LOCATION': 'session',
@aaugustin
aaugustin Nov 23, 2013

Note to self

The reason for this change isn't clear. Removing it makes a test fail:

======================================================================
FAIL: test_non_default_cache (django.contrib.sessions.tests.CacheSessionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/myk/Documents/dev/django/django/test/utils.py", line 217, in inner
    return test_func(*args, **kwargs)
  File "/Users/myk/Documents/dev/django/django/contrib/sessions/tests.py", line 500, in test_non_default_cache
    self.assertEqual(caches['default'].get(self.session.cache_key), None)
AssertionError: {} != None
@apollo13 apollo13 commented on an outdated diff Nov 23, 2013
django/core/management/commands/createcachetable.py
@@ -30,7 +30,7 @@ def handle(self, *tablenames, **options):
self.create_table(db, tablename)
else:
for cache_alias in settings.CACHES:
- cache = get_cache(cache_alias)
+ cache = create_cache(cache_alias)
@apollo13
apollo13 Nov 23, 2013

Shouldn't this be using 'caches'?

@apollo13 apollo13 commented on an outdated diff Nov 23, 2013
tests/cache/tests.py
@@ -55,7 +56,7 @@ class DummyCacheTests(unittest.TestCase):
backend_name = 'django.core.cache.backends.dummy.DummyCache'
def setUp(self):
- self.cache = get_cache(self.backend_name)
+ self.cache = create_cache(self.backend_name)
@apollo13
apollo13 Nov 23, 2013

s/create_cache/caches/?

@apollo13 apollo13 commented on an outdated diff Nov 23, 2013
tests/cache/tests.py
@@ -1314,7 +1320,7 @@ class CacheI18nTest(TestCase):
def setUp(self):
self.path = '/cache/test/'
- self.cache = get_cache('default')
+ self.cache = create_cache('default')
@apollo13
apollo13 Nov 23, 2013

s/create_cache/caches/

@apollo13 apollo13 commented on an outdated diff Nov 23, 2013
tests/cache/tests.py
@@ -1581,8 +1587,8 @@ class CacheMiddlewareTest(IgnoreDeprecationWarningsMixin, TestCase):
def setUp(self):
super(CacheMiddlewareTest, self).setUp()
self.factory = RequestFactory()
- self.default_cache = get_cache('default')
- self.other_cache = get_cache('other')
+ self.default_cache = create_cache('default')
+ self.other_cache = create_cache('other')
@apollo13
apollo13 Nov 23, 2013

s/create_cache/caches/

@apollo13 apollo13 commented on an outdated diff Nov 23, 2013
tests/cache/tests.py
@@ -1801,7 +1807,7 @@ class TestWithTemplateResponse(TestCase):
"""
def setUp(self):
self.path = '/cache/test/'
- self.cache = get_cache('default')
+ self.cache = create_cache('default')
@apollo13
apollo13 Nov 23, 2013

s/create_cache/caches/

@aaugustin
Django member

Merged in ffc37e2.

@aaugustin aaugustin closed this Nov 23, 2013
@aaugustin aaugustin deleted the aaugustin:new-cache-handler branch Nov 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment