#36506: sessions.backend.cache.SessionStore.clear_expired doesn't clean
----------------------------------+--------------------------------------
Reporter: Efe Öge | Owner: Efe Öge
Type: Bug | Status: assigned
Component: contrib.sessions | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Description changed by Efe Öge:
Old description:
> Hello,
>
> We've been using Redis as the session storage for our cache backend. 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.
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/36506#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701980af3a553-2d80a054-8a46-4a19-a2dc-9326e79237e9-000000%40eu-central-1.amazonses.com.