@@ -333,15 +333,13 @@ If an exception is handled or raised **outside** your decorated function, then i
333
333
334
334
This persistence layer is built-in, allowing you to use an existing DynamoDB table or create a new one dedicated to idempotency state (recommended).
335
335
336
- === "Customizing DynamoDBPersistenceLayer to suit your table structure"
337
-
338
- ```python hl_lines="7-15"
339
- --8<-- "examples/idempotency/src/customize_persistence_layer.py"
340
- ```
336
+ ``` python title="customize_persistence_layer.py" hl_lines="7-15"
337
+ -- 8 < -- " examples/idempotency/src/customize_persistence_layer.py"
338
+ ```
341
339
342
- ##### DynamoDB defaults
340
+ ##### DynamoDB attributes
343
341
344
- When using DynamoDB as the persistence layer, you can customize the attribute names by passing the following parameters during the initialization of the persistence layer :
342
+ You can customize the attribute names during initialization:
345
343
346
344
| Parameter | Required | Default | Description |
347
345
| --------------------------- | ------------------ | ------------------------------------ | -------------------------------------------------------------------------------------------------------- |
@@ -359,34 +357,34 @@ When using DynamoDB as the persistence layer, you can customize the attribute na
359
357
360
358
!!! info "We recommend Redis version 7 or higher for optimal performance."
361
359
362
- For a quick start , initialize ` RedisCachePersistenceLayer ` and pass your cluster host endpoint along with the port to connect to .
360
+ For simple setups , initialize ` RedisCachePersistenceLayer ` with your cluster endpoint and port to connect.
363
361
364
362
For security, we enforce SSL connections by default; to disable it, set ` ssl=False ` .
365
363
366
364
=== "Redis quick start"
367
- ```python hl_lines="7-9 12 26"
365
+ ```python title="getting_started_with_idempotency_redis_config.py" hl_lines="7-9 12 26"
368
366
--8<-- "examples/idempotency/src/getting_started_with_idempotency_redis_config.py"
369
367
```
370
368
371
369
=== "Using an existing Redis client"
372
- ```python hl_lines="4 9-11 14 22 36"
370
+ ```python title="getting_started_with_idempotency_redis_client.py" hl_lines="4 9-11 14 22 36"
373
371
--8<-- "examples/idempotency/src/getting_started_with_idempotency_redis_client.py"
374
372
```
375
373
376
374
=== "Sample event"
377
375
378
- ```json
376
+ ```json title="getting_started_with_idempotency_payload.json"
379
377
--8<-- "examples/idempotency/src/getting_started_with_idempotency_payload.json"
380
378
```
381
379
382
380
##### Redis SSL connections
383
381
384
382
We recommend using AWS Secrets Manager to store and rotate certificates safely, and the [ Parameters feature] ( ./parameters.md ) {target="_ blank"} to fetch and cache optimally.
385
383
386
- For advanced configurations, we also recommend using an existing Redis client for optimal compatibility like SSL certificates and timeout.
384
+ For advanced configurations, we recommend using an existing Redis client for optimal compatibility like SSL certificates and timeout.
387
385
388
386
=== "Advanced configuration using AWS Secrets"
389
- ```python hl_lines="9-11 13 15 25"
387
+ ```python title="using_redis_client_with_aws_secrets.py" hl_lines="9-11 13 15 25"
390
388
--8<-- "examples/idempotency/src/using_redis_client_with_aws_secrets.py"
391
389
```
392
390
@@ -400,7 +398,7 @@ For advanced configurations, we also recommend using an existing Redis client fo
400
398
```
401
399
402
400
=== "Advanced configuration with local certificates"
403
- ```python hl_lines="14 25-27"
401
+ ```python title="using_redis_client_with_local_certs.py" hl_lines="14 25-27"
404
402
--8<-- "examples/idempotency/src/using_redis_client_with_local_certs.py"
405
403
```
406
404
@@ -416,9 +414,9 @@ For advanced configurations, we also recommend using an existing Redis client fo
416
414
3. redis_user_private.key file stored in the "certs" directory of your Lambda function
417
415
4. redis_ca.pem file stored in the "certs" directory of your Lambda function
418
416
419
- ##### Redis defaults
417
+ ##### Redis attributes
420
418
421
- You can customize attribute names when instantiating ` RedisCachePersistenceLayer ` with the following parameters :
419
+ You can customize the attribute names during initialization :
422
420
423
421
| Parameter | Required | Default | Description |
424
422
| --------------------------- | -------- | ------------------------ | --------------------------------------------------------------------------------------------- |
@@ -427,11 +425,9 @@ You can customize attribute names when instantiating `RedisCachePersistenceLayer
427
425
| ** data_attr** | | ` data ` | Stores results of successfully executed Lambda handlers |
428
426
| ** validation_key_attr** | | ` validation ` | Hashed representation of the parts of the event used for validation |
429
427
430
- === "Customizing RedisPersistenceLayer to suit your data structure"
431
-
432
- ```python hl_lines="9-16"
433
- --8<-- "examples/idempotency/src/customize_persistence_layer_redis.py"
434
- ```
428
+ ``` python title="customize_persistence_layer_redis.py" hl_lines="9-16"
429
+ -- 8 < -- " examples/idempotency/src/customize_persistence_layer_redis.py"
430
+ ```
435
431
436
432
### Common use cases
437
433
0 commit comments