tornadio2.sessioncontainer

tornadio2.sessioncontainer

Simple heapq-based session implementation with sliding expiration window support.

class tornadio2.sessioncontainer.SessionBase(session_id=None, expiry=None)[source]

Represents one session object stored in the session container. Derive from this object to store additional data.

__init__(session_id=None, expiry=None)[source]

Constructor.

session_id
Optional session id. If not provided, will generate new session id.
expiry
Expiration time. If not provided, will never expire.
is_alive()[source]

Check if session is still alive

promote()[source]

Mark object as alive, so it won’t be collected during next run of the garbage collector.

on_delete(forced)[source]

Triggered when object was expired or deleted.

class tornadio2.sessioncontainer.SessionContainer[source]
add(session)[source]

Add session to the container.

session
Session object
get(session_id)[source]

Return session object or None if it is not available

session_id
Session identifier
remove(session_id)[source]

Remove session object from the container

session_id
Session identifier
expire(current_time=None)[source]

Expire any old entries

current_time
Optional time to be used to clean up queue (can be used in unit tests)