From 9da3e3f0f2f9f6299b546edcf7f70144ddfae624 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:42:04 +0000 Subject: [PATCH] Update idempotency.md Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- docs/utilities/idempotency.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/utilities/idempotency.md b/docs/utilities/idempotency.md index e6cefa3d..0d8f5339 100644 --- a/docs/utilities/idempotency.md +++ b/docs/utilities/idempotency.md @@ -253,6 +253,29 @@ If we were to treat the entire request as our idempotency key, a simple HTTP hea } ``` +### Custom key prefix + +By default, the idempotency key is prefixed with `[ClassName].[DecoratedMethodName]#[PayloadHash]`. + +You can customize this prefix by setting the `KeyPrefix` property in the Idempotency decorator: + +```csharp hl_lines="9" +public class Function +{ + public Function() + { + var tableName = Environment.GetEnvironmentVariable("IDEMPOTENCY_TABLE_NAME"); + Idempotency.Configure(builder => builder.UseDynamoDb(tableName)); + } + + [Idempotent(KeyPrefix = "MyCustomKeyPrefix")] + public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest apigwProxyEvent, ILambdaContext context) + { + return TestHelper.TestMethod(apigwProxyEvent); + } +} +``` + ### Lambda timeouts ???+ note