Skip to main content
Key-value actions store and retrieve values by key. This is useful for caching frequently accessed data, passing state between workflow executions, and implementing cache-aside patterns.
This storage is persistent — values survive a server restart. It is a simple key-value store, not a replacement for a database: for structured, queryable data use Data Operations.
This is unrelated to an agent’s accessMemory setting, which gives an agent file tools over its workspace. See AI Agents.

store_key

Stores a key-value pair in persistent storage.

Key

The unique identifier for storing the data. Use template syntax to create dynamic keys.
Include unique identifiers in your keys to avoid collisions. For example: user_{{ param "user_id" }} or cache_{{ .request_hash }}.

Value

The data to store. Can be any value, including JSON objects. Use {{ jsonout .action_result }} to store complex objects from previous actions.

Output

{{ .step_id }} holds the value that was stored.

Example

Store a user object:
Store a computed value:

get_key

Retrieves a value from persistent storage by key.

Key

The key to look up.

Fail If Empty

Whether to fail the step when the key is not set. When false, a missing key yields an empty result and the workflow continues.

Output

{{ .step_id }} holds the stored value, or is empty when the key is not set.

Example

Retrieve a cached user:
Require the key to exist:

Common Patterns

Cache-Aside Pattern

Check the cache first, fetch from the database if not found, then update the cache:

Session Storage

Store and retrieve user session data:

Rate Limiting Counter

Track request counts for rate limiting:

Temporary Token Storage

Store and validate temporary tokens:

Best Practices

Key Naming: Use consistent key naming conventions with prefixes to organize your data. For example: user_, session_, cache_, rate_.
Data Size: Keep stored values reasonably sized. For large datasets, consider storing only essential fields or IDs and fetching full data when needed.
No TTL: This store doesn’t support automatic expiration. Implement your own expiration logic by storing timestamps and checking them during retrieval.

Next Steps

Data Operations

Use a database for structured, queryable data.

Transformation

Process and transform cached data with JavaScript.

Flow Control

Combine caching with parallel data fetching.

Actions Overview

Learn the fundamentals of ServFlow actions.