@@ -16,6 +16,46 @@ import { BasePersistenceLayer } from './BasePersistenceLayer.js';
16
16
import { IdempotencyRecord } from './IdempotencyRecord.js' ;
17
17
import RedisConnection from './RedisConnection.js' ;
18
18
19
+ /**
20
+ * Redis persistence layer for idempotency records.
21
+ *
22
+ * This class uses Redis to write and read idempotency records. It supports both the default Redis client
23
+ * from @redis/client package as well as custom Redis clients.
24
+ *
25
+ * There are various options to configure the persistence layer, such as attribute names for storing
26
+ * status, expiry, data, and validation keys in Redis.
27
+ *
28
+ * With default configuration, you don't need to create the Redis client beforehand, the persistence layer
29
+ * will create it for you using the provided options. You can also bring your own Redis client by passing
30
+ * it through the `client` option.
31
+ *
32
+ * See the {@link https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/ Idempotency documentation}
33
+ * for more details on the Redis configuration and usage patterns.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { RedisPersistenceLayer } from '@aws-lambda-powertools/idempotency/redis';
38
+ *
39
+ * const persistence = await new RedisPersistenceLayer({ url: 'redis://localhost:6379' }).init();
40
+ * ```
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // Using your own Redis client
45
+ * import { createClient } from '@redis/client';
46
+ * import { RedisPersistenceLayer } from '@aws-lambda-powertools/idempotency/redis';
47
+ *
48
+ * const redisClient = createClient({ url: 'redis://localhost:6379' });
49
+ * await redisClient.connect();
50
+ *
51
+ * const persistence = new RedisPersistenceLayer({
52
+ * client: redisClient,
53
+ * });
54
+ * ```
55
+ *
56
+ * @see https://github.com/redis/node-redis/tree/master/packages/client
57
+ * @category Persistence Layer
58
+ */
19
59
class RedisPersistenceLayer extends BasePersistenceLayer {
20
60
readonly #client: RedisClientProtocol | RedisClientType | RedisClusterType ;
21
61
readonly #dataAttr: string ;
0 commit comments