Django

Code

Ticket #6791 (assigned)

Opened 4 months ago

Last modified 1 month ago

Cached DB Session Backend

Reported by: jhenry Assigned to: jdunck (accepted)
Milestone: 1.0 Component: django.contrib.sessions
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Right now, I consider the "cache" session backend to be broken, especially when used with the memcached session backend.

In a large memcached environment, servers enter and leave the memcached pool frequently. Each time this happens, the pool mapping changes and automatically logs users out (and loses their session data).

Attached is a new backend which is basically a copy of the DB session backend with a django.core.cache wrapper on accesses to the session data; all writes are write through to the database and cache and all reads come from memcache except in case of a memcache failure when it reads from the database.

Attachments

cached_db.diff (2.3 kB) - added by jhenry <jhenry@theonion.com> on 03/16/08 16:13:46.
cached_db_with_documentation.diff (3.5 kB) - added by mcroydon on 03/17/08 12:33:54.
Added documentation to patch against trunk
cached_db_docs_and_tests.diff (5.5 kB) - added by jdunck on 03/17/08 17:08:01.
Changed default session backend to cached_db. Changed docs to be betterer. ;-) Added tests.
cached_db_docs_and_tests-2.diff (4.7 kB) - added by jdunck on 03/26/08 15:08:22.
Last patch didn't include the actual code for cached_db backend. :-/

Change History

03/16/08 16:13:46 changed by jhenry <jhenry@theonion.com>

  • attachment cached_db.diff added.

03/17/08 12:33:54 changed by mcroydon

  • attachment cached_db_with_documentation.diff added.

Added documentation to patch against trunk

03/17/08 17:08:01 changed by jdunck

  • attachment cached_db_docs_and_tests.diff added.

Changed default session backend to cached_db. Changed docs to be betterer. ;-) Added tests.

03/17/08 17:08:36 changed by jdunck

  • owner changed from nobody to jdunck.
  • needs_better_patch changed.
  • status changed from new to assigned.
  • needs_tests changed.
  • needs_docs changed.

03/26/08 15:08:22 changed by jdunck

  • attachment cached_db_docs_and_tests-2.diff added.

Last patch didn't include the actual code for cached_db backend. :-/

03/26/08 15:10:05 changed by jdunck

After talking with Jacob, I reverted the default session backend to DB; changing the default is controversial, and this should be a simple win for interested people.

Anyway, cached_db_docs_and_tests-2.diff is the best; I somehow managed to leave cached_db.py out of my prior diff.

06/14/08 01:55:12 changed by Simon Greenhill

  • stage changed from Unreviewed to Ready for checkin.

06/22/08 09:37:42 changed by mrts

  • milestone set to 1.0.

Looks to be in scope for 1.0.


Add/Change #6791 (Cached DB Session Backend)




Change Properties
Action