You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/idempotency.md
+12-14Lines changed: 12 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,47 +119,45 @@ We recommend you start with a Redis compatible management services such as [Amaz
119
119
120
120
In both services and self-hosting Redis, you'll need to configure [VPC access](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html){target="_blank"} to your AWS Lambda.
121
121
122
-
!!! tip "First time setting it all up? Checkout the official tutorials for [Amazon ElastiCache for Redis](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/LambdaRedis.html) or [Amazon MemoryDB for Redis](https://aws.amazon.com/blogs/database/access-amazon-memorydb-for-redis-from-aws-lambda/)"
123
-
124
122
##### Redis IaC examples
125
123
126
124
=== "AWS CloudFormation example"
127
125
126
+
!!! tip inline end "Prefer AWS Console/CLI?"
127
+
128
+
Follow the official tutorials for [Amazon ElastiCache for Redis](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/LambdaRedis.html) or [Amazon MemoryDB for Redis](https://aws.amazon.com/blogs/database/access-amazon-memorydb-for-redis-from-aws-lambda/)
1. Replace the Security Group ID and Subnet ID to match your VPC settings.
133
135
2. Replace the Security Group ID and Subnet ID to match your VPC settings.
134
136
135
-
Once setup, you can find quick start and advanced examples for Redis in [the persistent layers section](RedisCachePersistenceLayer).
137
+
Once setup, you can find a quick start and advanced examples for Redis in [the persistent layers section](RedisCachePersistenceLayer).
136
138
137
139
<!-- markdownlint-enable MD013 -->
138
-
### Idempotent decorator
139
140
140
-
You can quickly start by initializing the `DynamoDBPersistenceLayer` class and using it with the `idempotent`decorator on your lambda handler.
141
+
### Idempotent decorator
141
142
142
-
???+ note
143
-
In this example, the entire Lambda handler is treated as a single idempotent operation. If your Lambda handler can cause multiple side effects, or you're only interested in making a specific logic idempotent, use [`idempotent_function`](#idempotent_function-decorator) instead.
143
+
For simple use cases, you can use the `idempotent` decorator on your Lambda handler function.
144
144
145
-
!!! tip "See [Choosing a payload subset for idempotency](#choosing-a-payload-subset-for-idempotency) for more elaborate use cases."
145
+
It will treat the entire event as an idempotency key. That is, the same event will return the previously stored result within a [configurable time window](#expiring-idempotency-records)_(1 hour, by default)_.
146
146
147
147
=== "Idempotent decorator"
148
148
149
-
```python hl_lines="4-7 10 24"
149
+
!!! tip "You can also choose [one or more fields](#choosing-a-payload-subset-for-idempotency) as an idempotency key."
After processing this request successfully, a second request containing the exact same payload above will now return the same response, ensuring our customer isn't charged twice.
160
-
161
-
!!! question "New to idempotency concept? Please review our [Terminology](#terminology) section if you haven't yet."
162
-
163
161
### Idempotent_function decorator
164
162
165
163
Similar to [idempotent decorator](#idempotent-decorator), you can use `idempotent_function` decorator for any synchronous Python function.
0 commit comments