THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class DatabaseSessionStore(ISessionStore): (source)
Constructor: DatabaseSessionStore(connection, table)
Session store that persists each session as a row in a database table.
Mirrors orionis.cache.stores.database.DatabaseCacheBackend:
records live in a dedicated table (id / payload /
expires_at) resolved through the session.connection
configuration, using upsert-by-retry semantics so no dialect-specific
ON CONFLICT syntax is required.
Unlike the cache backend, a plain SQL table has no native TTL, so
expired rows are evicted lazily on
orionis.session.stores.database.DatabaseSessionStore.read and can be swept
in
bulk via orionis.session.stores.database.DatabaseSessionStore.gc.
| Parameters | |
| connection | Database connection used to persist session records. |
| table | Table name used to store session records. Defaults to 'sessions'. |
| Method | __decode |
Deserialize a stored JSON payload back into a Python dict. |
| Method | __encode |
Serialize data to a JSON string suitable for storage. |
| Method | __init__ |
Bind the store to connection and the target table. |
| Async Method | __insert |
Insert a new session row, falling back to an update on conflict. |
| Async Method | _ensure |
Create the sessions table on first use, if missing. |
| Async Method | delete |
Remove the record for session_id (no-op when absent). |
| Async Method | gc |
Remove all rows whose expires_at is in the past. |
| Async Method | migrate |
Create the framework session table without removing existing data. |
| Async Method | read |
Return the stored record for session_id, or None. |
| Async Method | update |
Update only a live session row with a single SQL statement. |
| Async Method | write |
Insert or replace the record keyed by its identifier. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _connection |
Database connection used to persist session records. |
| Instance Variable | _definition |
Original declaration from which runtime metadata was compiled. |
| Instance Variable | _ready |
Ready flag used by DatabaseSessionStore. |
| Instance Variable | _ready |
Synchronization primitive controlling access to ready lock. |
| Instance Variable | _table |
Table name used to store session records. |
Deserialize a stored JSON payload back into a Python dict.
| Parameters | |
raw:str | bytes | None | Raw payload read from the payload column. |
| Returns | |
dict[str, typing.Any] | None | Decoded data, or None when raw is missing or invalid. |
Serialize data to a JSON string suitable for storage.
| Parameters | |
data:dict[str, typing.Any] | Session data payload to encode. |
| Returns | |
str | UTF-8 decoded JSON payload. |
Bind the store to connection and the target table.
| Parameters | |
connection:orionis.database.contracts.IConnection | Database connection used to persist session records. |
table:str, optional | Table name used to store session records. |
| Returns | |
None | No return value. |
Insert a new session row, falling back to an update on conflict.
Observe a failed retry separately and preserve the original insertion error when recovery cannot be confirmed.
| Parameters | |
sessionstr | Unique session identifier. |
payload:str | JSON-encoded session data already serialized by
orionis.session.stores.database.DatabaseSessionStore.write. |
expiration:int | Absolute expiration timestamp (whole epoch seconds). |
| Returns | |
None | No return value. |
Remove all rows whose expires_at is in the past.
Unlike a native TTL-backed cache, a SQL table never evicts stale rows on its own, so this performs a single bulk DELETE.
| Returns | |
None | No return value. |
Create the framework session table without removing existing data.
| Returns | |
None | No return value. |
| Raises | |
orionis.database.QueryException | If the connection cannot create the table. |
Return the stored record for session_id, or None.
| Parameters | |
sessionstr | Unique session identifier to look up. |
| Returns | |
orionis.session.entities.record.SessionRecord | None | The stored record, or None when absent, expired or corrupted. |
Update only a live session row with a single SQL statement.
| Parameters | |
record:orionis.session.entities.record.SessionRecord | Replacement payload and expiration. |
| Returns | |
bool | False when the session was deleted or expired. |
Insert or replace the record keyed by its identifier.
A record that has already expired is deleted instead of written.
| Parameters | |
record:orionis.session.entities.record.SessionRecord | The record to persist. |
| Returns | |
None | No return value. |