redis_backend#
- class starlite.middleware.session.redis_backend.RedisBackend#
Bases:
ServerSideBackend
[RedisBackendConfig
]Session backend to store data in redis.
- __init__(config: RedisBackendConfig) None #
Initialize
RedisBackend
.Notes
Requires
redis
. Install withpip install starlite[redis]
- async get(session_id: str) Optional[Union[bytes, str]] #
Load data associated with
session_id
from redis.- Parameters:
session_id – The session-ID
- Returns:
The session data, if existing, otherwise
None
.
- async set(session_id: str, data: bytes) None #
Store
data
in redis under<prefix>:<session_id>
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.redis_backend.RedisBackendConfig#
Bases:
ServerSideSessionConfig
Configuration for
RedisBackend
- redis: Redis#
redis.asyncio.Redis
instance.