8
8
from typing import Any , Literal , Protocol
9
9
10
10
import redis
11
+ from typing_extensions import deprecated
11
12
12
13
from aws_lambda_powertools .utilities .idempotency import BasePersistenceLayer
13
14
from aws_lambda_powertools .utilities .idempotency .exceptions import (
25
26
logger = logging .getLogger (__name__ )
26
27
27
28
29
+ @deprecated ("RedisPersistenceLayer will be removed in v4.0.0. Please use CacheProtocol instead." )
28
30
class RedisClientProtocol (Protocol ):
29
31
"""
30
- Protocol class defining the interface for a Redis client.
32
+ Protocol class defining the interface for a Cache client.
31
33
32
- This protocol outlines the expected behavior of a Redis client, allowing for
34
+ This protocol outlines the expected behavior of a Cache client, allowing for
33
35
standardization among different implementations and allowing customers to extend it
34
36
in their own implementation.
35
37
@@ -78,6 +80,7 @@ def delete(self, keys: bytes | str | memoryview) -> Any:
78
80
raise NotImplementedError
79
81
80
82
83
+ @deprecated ("RedisConnection will be removed in v4.0.0. Please use CacheConnection instead." )
81
84
class RedisConnection :
82
85
def __init__ (
83
86
self ,
@@ -91,26 +94,26 @@ def __init__(
91
94
ssl : bool = True ,
92
95
) -> None :
93
96
"""
94
- Initialize Redis connection which will be used in Redis persistence_store to support Idempotency
97
+ Initialize Cache connection which will be used in Cache persistence_store to support Idempotency
95
98
96
99
Parameters
97
100
----------
98
101
host: str, optional
99
- Redis host
102
+ Cache host
100
103
port: int, optional: default 6379
101
- Redis port
104
+ Cache port
102
105
username: str, optional
103
- Redis username
106
+ Cache username
104
107
password: str, optional
105
- Redis password
108
+ Cache password
106
109
url: str, optional
107
- Redis connection string, using url will override the host/port in the previous parameters
110
+ Cache connection string, using url will override the host/port in the previous parameters
108
111
db_index: int, optional: default 0
109
- Redis db index
112
+ Cache db index
110
113
mode: str, Literal["standalone","cluster"]
111
- set Redis client mode, choose from standalone/cluster. The default is standalone
114
+ set Cache client mode, choose from standalone/cluster. The default is standalone
112
115
ssl: bool, optional: default True
113
- set whether to use ssl for Redis connection
116
+ set whether to use ssl for Cache connection
114
117
115
118
Example
116
119
--------
@@ -122,8 +125,8 @@ def __init__(
122
125
from aws_lambda_powertools.utilities.idempotency import (
123
126
idempotent,
124
127
)
125
- from aws_lambda_powertools.utilities.idempotency.persistence.redis import (
126
- RedisCachePersistenceLayer ,
128
+ from aws_lambda_powertools.utilities.idempotency.persistence.cache import (
129
+ CachePersistenceLayer ,
127
130
)
128
131
129
132
from aws_lambda_powertools.utilities.typing import LambdaContext
@@ -204,6 +207,7 @@ def _init_client(self) -> RedisClientProtocol:
204
207
raise IdempotencyPersistenceConnectionError ("Could not to connect to Redis" , exc ) from exc
205
208
206
209
210
+ @deprecated ("RedisCachePersistenceLayer will be removed in v4.0.0. Please use CachePersistenceLayer instead." )
207
211
class RedisCachePersistenceLayer (BasePersistenceLayer ):
208
212
def __init__ (
209
213
self ,
0 commit comments