Opened 12 years ago
Closed 12 years ago
#21000 closed Bug (fixed)
Session cached_db backend doesn't use SESSION_CACHE_ALIAS
| Reported by: | CHI Cheng | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.sessions | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
cached_db always use default cache backend
Change History (4)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
Patch looks OK, it would be nice to add tests (or a strong rationale as to why they're impossible to write; I can't remember what support for testing multiple caches we currently have).
This is worth mentioning in the release notes too.
comment:3 by , 12 years ago
Added a small test.
A weird thing: the previous code could also pass this test: (copied from CacheSessionTests in contrib/sessions/tests.py)
@override_settings(CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
},
'sessions': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
}, SESSION_CACHE_ALIAS='sessions')
def test_non_default_cache(self):
# Re-initalize the session backend to make use of overridden settings.
self.session = self.backend()
self.session.save()
self.assertEqual(get_cache('default').get(self.session.cache_key), None)
self.assertNotEqual(get_cache('sessions').get(self.session.cache_key), None) # Should fail here as previous code always use `default` cache
comment:4 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/1531