Memory storage persists across workflow executions but is cleared when the server restarts. For persistent storage, use Data Operations.
memory_store
Stores data in temporary memory using a key-value pattern.Key
The unique identifier for storing the data. Use template syntax to create dynamic keys.Contents
The data to store. Can be any value, including JSON objects.
Use
{{ jsonout .action_result }} to store complex objects from previous actions.
Example
Store a user object in memory:memory_fetch
Retrieves data from temporary memory storage using a key.Key
The key to look up in memory storage.Example
Retrieve a cached user:{{ .get_cached_user }}. If the key doesn’t exist, the result will be empty.
Common Patterns
Cache-Aside Pattern
Check the cache first, fetch from 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
Data Size: Keep stored values reasonably sized. For large datasets, consider storing only essential fields or IDs and fetching full data when needed.
Next Steps
Data Operations
Use persistent database storage for long-term 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.