An asynchronous session backend with mongodb for tornado.
Project description
Torsession is an async && sync session backend with Mongodb for Tornado.
Installation
$ pip install torsession
Example
Async example.
from torsession.async import SessionManager
# Initialize SessionManager
sm = SessionManager(motor.MotorClient())
# create a new session or load a session
session = yield sm.new_session()
session = yield sm.load_session("session id")
# set a key-value pair
yield session.set(key, val)
# get key
val = yield session.get(key)
# delete a key
yield session.delete(key)
# refresh session id
yield session.refresh_id()
# clear a session
yield session.clear()
Sync example.
from torsession.sync import SessionManager
# Initialize SessionManager
sm = SessionManager(pymongo.MotorClient())
# create a new session or load a session
session = sm.new_session()
session = sm.load_session("session id")
# set a key-value pair
session.set(key, val)
# get key
val = session.get(key)
# delete a key
session.delete(key)
# refresh session id
session.refresh_id()
# clear a session
session.clear()
LICENSE
MIT
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 Distribution
torsession-0.2.6.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for torsession-0.2.6-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d95aaf7afd60eb236ad87fab62ad3248680a45f7d69254c63ffcd04f50f91bf |
|
MD5 | ceae2c0e9b7c20f52c7fef95a25a905c |
|
BLAKE2b-256 | fe8d5f9890d6f99cdd88c785ff253023252365c1cc48d0778d3ba9727ed4f282 |