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
Original file line number
Diff line number
Diff line change
@@ -122,47 +122,45 @@ We recommend you start with a Redis compatible management services such as [Amaz
122
122
123
123
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.
124
124
125
-
!!! 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/)"
126
-
127
125
##### Redis IaC examples
128
126
129
127
=== "AWS CloudFormation example"
130
128
129
+
!!! tip inline end "Prefer AWS Console/CLI?"
130
+
131
+
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.
136
138
2. Replace the Security Group ID and Subnet ID to match your VPC settings.
137
139
138
-
Once setup, you can find quick start and advanced examples for Redis in [the persistent layers section](RedisCachePersistenceLayer).
140
+
Once setup, you can find a quick start and advanced examples for Redis in [the persistent layers section](RedisCachePersistenceLayer).
139
141
140
142
<!-- markdownlint-enable MD013 -->
141
-
### Idempotent decorator
142
143
143
-
You can quickly start by initializing the `DynamoDBPersistenceLayer` class and using it with the `idempotent`decorator on your lambda handler.
144
+
### Idempotent decorator
144
145
145
-
???+ note
146
-
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.
146
+
For simple use cases, you can use the `idempotent` decorator on your Lambda handler function.
147
147
148
-
!!! tip "See [Choosing a payload subset for idempotency](#choosing-a-payload-subset-for-idempotency) for more elaborate use cases."
148
+
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)_.
149
149
150
150
=== "Idempotent decorator"
151
151
152
-
```python hl_lines="4-7 10 24"
152
+
!!! 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.
163
-
164
-
!!! question "New to idempotency concept? Please review our [Terminology](#terminology) section if you haven't yet."
165
-
166
164
### Idempotent_function decorator
167
165
168
166
Similar to [idempotent decorator](#idempotent-decorator), you can use `idempotent_function` decorator for any synchronous Python function.
0 commit comments