Shared State Storage
Simple cache to store Process data between executions.
Shared State Storage provides a temporary caching mechanism for data that needs to persist across Process executions or be shared between different Processes. Instead of setting up a dedicated database or external storage, you can use Shared State to maintain information like authentication tokens, counters, or temporary configuration data.
Temporary Memory
Shared State works as a key-value store where each entry lives for a specific duration before being automatically cleaned up. You define how long data should remain available by setting a Time To Live (TTL) ranging from one minute to 30 days. Once the TTL expires, the system removes the data automatically.
The data itself is stored in the Agent Group's database as JSON-serializable values. This means you can store simple strings and numbers, but also complex objects and arrays, as long as they can be represented in JSON format.
Data visibility can be configured in two ways:
Process-specific: The data is only accessible within the Process that created it.
Agent Group-wide: The data is accessible by any Process running in the same Agent Group.
When using Agent Group-wide sharing, all Agents must have access to the same database. For single-Agent setups using SQLite, the storage remains local to that Agent. In High Availability environments with multiple Agents, a centralized database like SQL Server ensures consistent access across all Agents. SQLite is not recommended for HA setups due to potential concurrency issues.
Token Caching
A common use case for Shared State is caching authentication tokens. When your Process needs to call an API that requires authentication, fetching a new token for every execution wastes time and resources. Instead, you can retrieve a token from Shared State, and only request a new one when the cached token is missing or has expired.
By setting the TTL slightly shorter than the actual token expiration, you ensure the cached token remains valid when retrieved. This approach works particularly well when multiple Processes need to access the same API, as they can all share the same cached token across the Agent Group.
Process Coordination
Sometimes you need multiple Processes to coordinate their behavior or share information. Shared State provides a lightweight way to exchange data without building complex integrations. One Process can store configuration settings, status flags, or partial results that other Processes read to determine their next actions.
This works well for implementing patterns like rate limiting, where a Process stores a counter in Shared State before performing an operation. Subsequent executions check and update the counter, ensuring operations stay within defined thresholds. The automatic expiration of entries helps reset counters without manual intervention.
Technical Reference
Read more about how to implement Shared State Storage usage using Shared State Task from its reference page.
Last updated
Was this helpful?

