From b7093a931c38d55d381c666f0bc5c0916ecb1b8d Mon Sep 17 00:00:00 2001 From: Brandon Warner Date: Fri, 30 Aug 2024 16:38:26 -0400 Subject: [PATCH] Add support for redis clusters --- src/flask_session/redis/redis.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flask_session/redis/redis.py b/src/flask_session/redis/redis.py index abed80df..5e49a654 100644 --- a/src/flask_session/redis/redis.py +++ b/src/flask_session/redis/redis.py @@ -3,7 +3,7 @@ from typing import Optional from flask import Flask -from redis import Redis +from redis import Redis, RedisCluster from .._utils import total_seconds from ..base import ServerSideSession, ServerSideSessionInterface @@ -40,14 +40,14 @@ class RedisSessionInterface(ServerSideSessionInterface): def __init__( self, app: Flask, - client: Optional[Redis] = Defaults.SESSION_REDIS, + client: Optional[Redis | RedisCluster] = Defaults.SESSION_REDIS, key_prefix: str = Defaults.SESSION_KEY_PREFIX, use_signer: bool = Defaults.SESSION_USE_SIGNER, permanent: bool = Defaults.SESSION_PERMANENT, sid_length: int = Defaults.SESSION_ID_LENGTH, serialization_format: str = Defaults.SESSION_SERIALIZATION_FORMAT, ): - if client is None or not isinstance(client, Redis): + if client is None or not (isinstance(client, Redis) or isinstance(client, RedisCluster)): warnings.warn( "No valid Redis instance provided, attempting to create a new instance on localhost with default settings.", RuntimeWarning,