Skip to content

Commit b9a0ee6

Browse files
author
Michael Brewer
committed
docs(idempotency): Correct examples and line highlights
1 parent b0ba6f2 commit b9a0ee6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/utilities/idempotency.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ You can quickly start by initializing the `DynamoDBPersistenceLayer` class and u
8484

8585
=== "app.py"
8686

87-
```python hl_lines="1 5 7 14"
87+
```python hl_lines="1-3 5 7 14"
8888
from aws_lambda_powertools.utilities.idempotency import (
8989
DynamoDBPersistenceLayer, idempotent
9090
)
@@ -186,7 +186,7 @@ Imagine the function executes successfully, but the client never receives the re
186186
"time":"10/Feb/2021:13:40:43 +0000",
187187
"timeEpoch":1612964443723
188188
},
189-
"body":"{\"username\":\"xyz\",\"product_id\":\"123456789\"}",
189+
"body":"{\"user\":\"xyz\",\"product_id\":\"123456789\"}",
190190
"isBase64Encoded":false
191191
}
192192
```
@@ -223,7 +223,7 @@ This persistence layer is built-in, and you can either use an existing DynamoDB
223223

224224
=== "app.py"
225225

226-
```python hl_lines="3-7"
226+
```python hl_lines="5-9"
227227
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer
228228

229229
persistence_layer = DynamoDBPersistenceLayer(
@@ -232,7 +232,7 @@ This persistence layer is built-in, and you can either use an existing DynamoDB
232232
expiry_attr="expires_at",
233233
status_attr="current_status",
234234
data_attr="result_data",
235-
validation_key_attr="validation_key"
235+
validation_key_attr="validation_key",
236236
)
237237
```
238238

@@ -246,6 +246,7 @@ Parameter | Required | Default | Description
246246
**status_attr** | | `status` | Stores status of the lambda execution during and after invocation
247247
**data_attr** | | `data` | Stores results of successfully executed Lambda handlers
248248
**validation_key_attr** | | `validation` | Hashed representation of the parts of the event used for validation
249+
249250
## Advanced
250251

251252
### Customizing the default behavior
@@ -259,7 +260,7 @@ Parameter | Default | Description
259260
**raise_on_no_idempotency_key** | `False` | Raise exception if no idempotency key was found in the request
260261
**expires_after_seconds** | 3600 | The number of seconds to wait before a record is expired
261262
**use_local_cache** | `False` | Whether to locally cache idempotency results
262-
**local_cache_max_items** | 1024 | Max number of items to store in local cache
263+
**local_cache_max_items** | 256 | Max number of items to store in local cache
263264
**hash_function** | `md5` | Function to use for calculating hashes, as provided by [hashlib](https://docs.python.org/3/library/hashlib.html) in the standard library.
264265

265266
### Handling concurrent executions with the same payload
@@ -281,16 +282,15 @@ You can enable in-memory caching with the **`use_local_cache`** parameter:
281282

282283
=== "app.py"
283284

284-
```python hl_lines="6 8 11"
285+
```python hl_lines="8 11"
285286
from aws_lambda_powertools.utilities.idempotency import (
286287
IdempotencyConfig, DynamoDBPersistenceLayer, idempotent
287288
)
288289

289290
persistence_layer = DynamoDBPersistenceLayer(table_name="IdempotencyTable")
290291
config = IdempotencyConfig(
291292
event_key_jmespath="body",
292-
expires_after_seconds=5*60, # 5 minutes
293-
use_local_cache=True
293+
use_local_cache=True,
294294
)
295295

296296
@idempotent(config=config, persistence_store=persistence_layer)
@@ -310,7 +310,7 @@ You can change this window with the **`expires_after_seconds`** parameter:
310310

311311
=== "app.py"
312312

313-
```python hl_lines="6 8 11"
313+
```python hl_lines="8 11"
314314
from aws_lambda_powertools.utilities.idempotency import (
315315
IdempotencyConfig, DynamoDBPersistenceLayer, idempotent
316316
)

0 commit comments

Comments
 (0)