@@ -48,23 +48,25 @@ def delete(self, keys: bytes | str | memoryview) -> Any:
48
48
class RedisConnection :
49
49
def __init__ (
50
50
self ,
51
+ url : str = "" ,
51
52
host : str = "" ,
53
+ port : int = 6379 ,
52
54
username : str = "" ,
53
55
password : str = "" , # nosec - password for Redis connection
54
- url : str = "" ,
55
56
db_index : int = 0 ,
56
- port : int = 6379 ,
57
57
mode : Literal ["standalone" , "cluster" ] = "standalone" ,
58
58
ssl : bool = False ,
59
59
ssl_cert_reqs : Literal ["required" , "optional" , "none" ] = "none" ,
60
60
) -> None :
61
61
"""
62
- Initialize Redis connection which will be used in redis persistence_store to support idempotency
62
+ Initialize Redis connection which will be used in redis persistence_store to support Idempotency
63
63
64
64
Parameters
65
65
----------
66
66
host: str, optional
67
67
redis host
68
+ port: int, optional: default 6379
69
+ redis port
68
70
username: str, optional
69
71
redis username
70
72
password: str, optional
@@ -73,10 +75,8 @@ def __init__(
73
75
redis connection string, using url will override the host/port in the previous parameters
74
76
db_index: str, optional: default 0
75
77
redis db index
76
- port: int, optional: default 6379
77
- redis port
78
78
mode: str, Literal["standalone","cluster"]
79
- set redis client mode, choose from standalone/cluster
79
+ set redis client mode, choose from standalone/cluster. The default is standalone
80
80
ssl: bool, optional: default False
81
81
set whether to use ssl for Redis connection
82
82
ssl_cert_reqs: str, optional: default "none"
@@ -138,7 +138,7 @@ def create_subscription_payment(event: dict) -> Payment:
138
138
self .mode = mode
139
139
140
140
def _init_client (self ) -> RedisClientProtocol :
141
- logger .info (f"Trying to connect to Redis: { self .host } " )
141
+ logger .debug (f"Trying to connect to Redis: { self .host } " )
142
142
client : type [redis .Redis | redis .cluster .RedisCluster ]
143
143
if self .mode == "standalone" :
144
144
client = redis .Redis
@@ -171,12 +171,12 @@ def _init_client(self) -> RedisClientProtocol:
171
171
class RedisCachePersistenceLayer (BasePersistenceLayer ):
172
172
def __init__ (
173
173
self ,
174
+ url : str = "" ,
174
175
host : str = "" ,
176
+ port : int = 6379 ,
175
177
username : str = "" ,
176
178
password : str = "" , # nosec - password for Redis connection
177
- url : str = "" ,
178
179
db_index : int = 0 ,
179
- port : int = 6379 ,
180
180
mode : Literal ["standalone" , "cluster" ] = "standalone" ,
181
181
ssl : bool = False ,
182
182
ssl_cert_reqs : Literal ["required" , "optional" , "none" ] = "none" ,
@@ -193,6 +193,8 @@ def __init__(
193
193
----------
194
194
host: str, optional
195
195
redis host
196
+ port: int, optional: default 6379
197
+ redis port
196
198
username: str, optional
197
199
redis username
198
200
password: str, optional
@@ -201,8 +203,6 @@ def __init__(
201
203
redis connection string, using url will override the host/port in the previous parameters
202
204
db_index: str, optional: default 0
203
205
redis db index
204
- port: int, optional: default 6379
205
- redis port
206
206
mode: str, Literal["standalone","cluster"]
207
207
set redis client mode, choose from standalone/cluster
208
208
ssl: bool, optional: default False
@@ -231,7 +231,7 @@ def __init__(
231
231
from aws_lambda_powertools.utilities.data_class import(
232
232
RedisCachePersistenceLayer,
233
233
)
234
- from aws_lambda_powertools.utilities.idempotency.idempotency import (
234
+ from aws_lambda_powertools.utilities.idempotency import (
235
235
idempotent,
236
236
)
237
237
@@ -271,7 +271,7 @@ def lambda_handler(event: dict, context: LambdaContext):
271
271
272
272
if not hasattr (self .client , "get_connection_kwargs" ):
273
273
raise IdempotencyRedisClientConfigError (
274
- "Error configuring the Redis Client. The client must implement get_connection_kwargs function." ,
274
+ "Error configuring the Redis Client. The Redis library must implement get_connection_kwargs function." ,
275
275
)
276
276
if not self .client .get_connection_kwargs ().get ("decode_responses" , False ):
277
277
warnings .warn (
0 commit comments