1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00

Made a few small tweaks to reduce persistent storage accesses in the session

backend. Refs #8311, although doesn't fix the problem there.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8381 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-08-15 14:59:11 +00:00
parent 93462f9516
commit 0d48087a53
4 changed files with 11 additions and 1 deletions

View File

@ -121,7 +121,11 @@ class SessionBase(object):
return self._session.iteritems()
def clear(self):
self._session.clear()
# To avoid unnecessary persistent storage accesses, we set up the
# internals directly (loading data wastes time, since we are going to
# set it to an empty dict anyway).
self._session_cache = {}
self.accessed = True
self.modified = True
def _get_new_session_key(self):

View File

@ -42,6 +42,8 @@ class SessionStore(SessionBase):
def delete(self, session_key=None):
if session_key is None:
if self._session_key is None:
return
session_key = self._session_key
self._cache.delete(session_key)

View File

@ -63,6 +63,8 @@ class SessionStore(SessionBase):
def delete(self, session_key=None):
if session_key is None:
if self._session_key is None:
return
session_key = self._session_key
try:
Session.objects.get(session_key=session_key).delete()

View File

@ -94,6 +94,8 @@ class SessionStore(SessionBase):
def delete(self, session_key=None):
if session_key is None:
if self._session_key is None:
return
session_key = self._session_key
try:
os.unlink(self._key_to_file(session_key))