Opened 8 weeks ago
Last modified 7 weeks ago
#36506 closed Bug
sessions.backend.cache.SessionStore.clear_expired doesn't clean — at Version 3
Reported by: | Efe Öge | Owned by: | Efe Öge |
---|---|---|---|
Component: | contrib.sessions | Version: | 5.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hello,
We've been using Redis as cache backend for session storage. To clean up old sessions, we run the "python manage.py clearsessions" management command. This command internally calls the clear_expired method on the associated SessionStore. If clear_expired raises a NotImplementedError, the command catches it and raises a CommandError, indicating that the session backend doesn't support session cleanup. This behavior makes sense. https://github.com/django/django/blob/main/django/contrib/sessions/management/commands/clearsessions.py
However, in the case of the cache backend, the clear_expired method is currently just an empty function. https://github.com/django/django/blob/main/django/contrib/sessions/backends/cache.py#L140
I would therefore recommend either explicitly raising a NotImplementedError here, or implementing a (potentially slow) cleanup mechanism that actually removes expired sessions.
What are your thoughts on this? If this looks like a bug to you, I’d be happy to help by sending a patch.
Change History (3)
comment:1 by , 8 weeks ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 8 weeks ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 8 weeks ago
Description: | modified (diff) |
---|