#36506: sessions.backend.cache.SessionStore.clear_expired doesn't clean
-------------------------+--------------------------------------------
     Reporter:  Efe Öge  |                     Type:  Uncategorized
       Status:  new      |                Component:  contrib.sessions
      Version:  5.2      |                 Severity:  Normal
     Keywords:           |             Triage Stage:  Unreviewed
    Has patch:  0        |      Needs documentation:  0
  Needs tests:  0        |  Patch needs improvement:  0
Easy pickings:  0        |                    UI/UX:  0
-------------------------+--------------------------------------------
 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.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36506>
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/010701980adc650b-07735a5b-00d1-4443-a45b-8949b6b292bc-000000%40eu-central-1.amazonses.com.

Reply via email to