Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Optimized the cached_db session backend to check if a key exists in t…

…he cache first.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c11f9c3193901215ec79732af6ab6c66b3c1c2ba 1 parent bda21e2
Aymeric Augustin aaugustin authored
2  django/contrib/sessions/backends/
@@ -28,6 +28,8 @@ def load(self):
return data
def exists(self, session_key):
+ if (KEY_PREFIX + session_key) in cache:
+ return True
return super(SessionStore, self).exists(session_key)
def save(self, must_create=False):
5 django/contrib/sessions/
@@ -293,6 +293,11 @@ class CacheDBSessionTests(SessionTestsMixin, TestCase):
backend = CacheDBSession
+ def test_exists_searches_cache_first(self):
+ with self.assertNumQueries(0):
+ self.assertTrue(self.session.exists(self.session.session_key))
CacheDBSessionWithTimeZoneTests = override_settings(USE_TZ=True)(CacheDBSessionTests)
Please sign in to comment.
Something went wrong with that request. Please try again.