memory_backend#
- class starlite.middleware.session.memory_backend.MemoryBackend#
Bases:
ServerSideBackend
[MemoryBackendConfig
]Session backend to store data in memory.
- __init__(config: MemoryBackendConfig) None #
Initialize
MemoryBackend
.- Parameters:
config – An instance of
MemoryBackendConfig
Warning
This should not be used in production and serves mainly as a dummy backend for easy testing. It is not process-safe, and data won’t be persisted
- async get(session_id: str) Optional[bytes] #
Retrieve data associated with
session_id
.- Parameters:
session_id – The session-ID
- Returns:
The session data, if existing, otherwise
None
.
- async set(session_id: str, data: bytes) None #
Store
data
under thesession_id
for later retrieval.If there is already data associated with
session_id
, replace it withdata
and reset its expiry time- Parameters:
session_id – The session-ID
data – Serialized session data
- Returns:
None
- class starlite.middleware.session.memory_backend.MemoryBackendConfig#
Bases:
ServerSideSessionConfig
Configuration for
MemoryBackend