diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md index 1b3538f9a..09552c6dd 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md @@ -28,10 +28,12 @@ Refer to the TTL column in the [state store components guide]({{< ref supported- You can set state TTL in the metadata as part of the state store set request: -{{< tabs Python "HTTP API (Bash)" "HTTP API (PowerShell)">}} +{{< tabs Python ".NET" Java Go "HTTP API (Bash)" "HTTP API (PowerShell)">}} {{% codetab %}} + + ```python #dependencies @@ -58,6 +60,73 @@ dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-g {{% codetab %}} + + +```csharp +// dependencies + +using Dapr.Client; + +// code + +await client.SaveStateAsync(storeName, stateKeyName, state, metadata: new Dictionary() { + { + "metadata.ttlInSeconds", "120" + } +}); +``` + +To launch a Dapr sidecar and run the above example application, you'd then run a command similar to the following: + +```bash +dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 dotnet run +``` + +{{% /codetab %}} + +{{% codetab %}} + + + +```java +//dependencies + + +//code + + +``` + +To launch a Dapr sidecar and run the above example application, you'd then run a command similar to the following: + +```bash +dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 mvn spring-boot:run +``` + +{{% /codetab %}} + +{{% codetab %}} + + + +```go +// dependencies + + +// code + +``` + +To launch a Dapr sidecar and run the above example application, you'd then run a command similar to the following: + +```bash +dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 go run OrderProcessingService.go +``` + +{{% /codetab %}} + +{{% codetab %}} + ```bash curl -X POST -H "Content-Type: application/json" -d '[{ "key": "order_1", "value": "250", "metadata": { "ttlInSeconds": "120" } }]' http://localhost:3601/v1.0/state/statestore ```