diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/actors-overview.md b/daprdocs/content/en/developing-applications/building-blocks/actors/actors-overview.md index bda74c2a5..eed874969 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/actors-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/actors-overview.md @@ -86,6 +86,13 @@ The Dapr actor runtime provides a simple turn-based access model for accessing a - [Learn more about actor reentrancy]({{< ref "actor-reentrancy.md" >}}) - [Learn more about the turn-based access model]({{< ref "actors-features-concepts.md#turn-based-access" >}}) +### State + +Transactional state stores can be used to store actor state. To specify which state store to use for actors, specify value of property `actorStateStore` as `true` in the state store component's metadata section. Actors state is stored with a specific scheme in transactional state stores, allowing for consistent querying. Only a single state store component can be used as the state store for all actors. Read the [state API reference]({{< ref state_api.md >}}) and the [actors API reference]({{< ref actors_api.md >}}) to learn more about state stores for actors. + +#### Time to Live (TTL) on state +You should always set the TTL metadata field (`ttlInSeconds`), or the equivalent API call in your chosen SDK when saving actor state to ensure that state eventually removed. Read [actors overview]({{< ref actors-overview.md >}}) for more information. + ### Actor timers and reminders Actors can schedule periodic work on themselves by registering either timers or reminders. @@ -105,4 +112,4 @@ This distinction allows users to trade off between light-weight but stateless ti ## Related links - [Actors API reference]({{< ref actors_api.md >}}) -- Refer to the [Dapr SDK documentation and examples]({{< ref "developing-applications/sdks/#sdk-languages" >}}). \ No newline at end of file +- Refer to the [Dapr SDK documentation and examples]({{< ref "developing-applications/sdks/#sdk-languages" >}}). diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md index f9f5813f0..a7dacc361 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md @@ -93,6 +93,9 @@ You can group write, update, and delete operations into a request, which are the Transactional state stores can be used to store actor state. To specify which state store to use for actors, specify value of property `actorStateStore` as `true` in the state store component's metadata section. Actors state is stored with a specific scheme in transactional state stores, allowing for consistent querying. Only a single state store component can be used as the state store for all actors. Read the [state API reference]({{< ref state_api.md >}}) and the [actors API reference]({{< ref actors_api.md >}}) to learn more about state stores for actors. +#### Time to Live (TTL) on actor state +You should always set the TTL metadata field (`ttlInSeconds`), or the equivalent API call in your chosen SDK when saving actor state to ensure that state eventually removed. Read [actors overview]({{< ref actors-overview.md >}}) for more information. + ### State encryption Dapr supports automatic client encryption of application state with support for key rotations. This is supported on all Dapr state stores. For more info, read the [How-To: Encrypt application state]({{< ref howto-encrypt-state.md >}}) topic. @@ -178,4 +181,4 @@ Want to skip the quickstarts? Not a problem. You can try out the state managemen - [How-To: Build a stateful service]({{< ref howto-stateful-service.md >}}) - Review the list of [state store components]({{< ref supported-state-stores.md >}}) - Read the [state management API reference]({{< ref state_api.md >}}) -- Read the [actors API reference]({{< ref actors_api.md >}}) \ No newline at end of file +- Read the [actors API reference]({{< ref actors_api.md >}}) diff --git a/daprdocs/content/en/reference/api/actors_api.md b/daprdocs/content/en/reference/api/actors_api.md index 81ee3cf79..edd6a46ff 100644 --- a/daprdocs/content/en/reference/api/actors_api.md +++ b/daprdocs/content/en/reference/api/actors_api.md @@ -75,6 +75,14 @@ Persists the change to the state for an actor as a multi-item transaction. ***Note that this operation is dependant on a using state store component that supports multi-item transactions.*** +When putting state, _always_ set the `ttlInSeconds` field in the +metadata for each value, unless there is a state clean up process out of band of +Dapr. Omitting this field will result in the underlying Actor state store to +grow indefinitely. + +See the Dapr Community Call 80 recording for more details on actor state TTL. + + #### HTTP Request ``` @@ -109,7 +117,10 @@ curl -X POST http://localhost:3500/v1.0/actors/stormtrooper/50/state \ "operation": "upsert", "request": { "key": "key1", - "value": "myData" + "value": "myData", + "metadata": { + "ttlInSeconds": "3600" + } } }, {