Efficiently clear expired sessions from the database.
Project description
By default, Django’s cached_db and db session backends loop through deleted sessions in order to trigger pre/post delete signal handlers. This can be extremely slow and consume a lot of CPU and memory on sites with a lot of sessions.
This package provides a SessionStoreMixin class and alternative cached_db and db backends that use the private _raw_delete() method, which is much faster and consumes much less CPU and memory, but does not trigger pre/post delete signal handlers.
Usage
Add to your settings:
SESSION_ENGINE = 'django_raw_clearsessions.cached_db'
Or:
SESSION_ENGINE = 'django_raw_clearsessions.db'
Or:
# mybackend.py from some.package import some_backend from django_raw_clearsessions import SessionStoreMixin class SessionStore(SessionStoreMixin, some_backend.SessionStore): pass # settings.py SESSION_ENGINE = 'mybackend'
Execute the Django clearsessions management command:
$ python manage.py clearsessions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_raw_clearsessions-0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dadf4665bddf311c6414fc2d4630e7d98e07d4e1997d83f290b564f5d7204d8f |
|
MD5 | 4c4a538ee5bb0ea72dbe01b16f321b11 |
|
BLAKE2b-256 | ed92ad32222d18835b903d5e11118a2a8e1a3633af19fc5650f15859a2e7a95e |