Skip to main content

mongodb as Django sessions backend

Project description

Info:

mongodb as Django sessions backend

https://api.travis-ci.org/hellysmile/django-mongo-sessions.png

features

  • fast NoSQL Django sessions backend

  • invalidation via TTL

installation

run pip install django-mongo-sessions

set mongo_sessions.session as session engine:

SESSION_ENGINE = 'mongo_sessions.session'

settings

there is two ways to setup mongodb connection at settings.py

first, if already have mongo connection, like:

import pymongo
from pymongo import MongoClient
connection = MongoClient()
MONGO_CLIENT = connection.your_database
MONGO_SESSIONS_COLLECTION = 'mongo_sessions' # default option

second, if you need to connect to mongodb, like:

MONGO_PORT = 27017
MONGO_HOST = 'localhost'
MONGO_DB_NAME = 'test'
MONGO_DB_USER = False
MONGO_DB_PASSWORD = False
MONGO_SESSIONS_COLLECTION = 'mongo_sessions'

# all this settings are defaults, you can skip any

expireAfterSeconds index value by default is SESSION_COOKIE_AGE you can change:

MONGO_SESSIONS_TTL = 60 * 60 # one hour

be sure, that you know what are you doing with it, SESSION_COOKIE_AGE will get different expiration time

every time you change one of this values, expireAfterSeconds index will be dropped and then will be indexed with insureIndex again, be careful here

it is good way to change expireAfterSeconds only by 1 running instance

tests:

pip install tox
tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-mongo-sessions-0.0.3.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file django-mongo-sessions-0.0.3.tar.gz.

File metadata

File hashes

Hashes for django-mongo-sessions-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b62a3012d6eafeaa72a0563c9257c7c290bf62a46102339dff568d1a3003f75c
MD5 8616cf5ac78eb3e672e1c22945e26afe
BLAKE2b-256 0084d8cede431b25b1e7e452cf9a36e9ff30ffec799d1a47de2889addf4db440

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page