Overview
This node provides an in-memory key-value store (KVS) with configurable scopes for storing and retrieving data during workflow executions. It supports setting, getting, deleting, and clearing key-value pairs within three different scopes: execution, workflow, and instance. This flexibility allows users to persist data temporarily or across multiple workflow runs or even share data globally across all workflows in the n8n instance.
Common scenarios include:
- Caching intermediate results during a workflow execution.
- Persisting state or counters across multiple executions of the same workflow.
- Sharing configuration or state data globally across all workflows running on the same n8n instance.
For example, you could use this node to count how many times a particular event has occurred during a workflow run (execution scope), store user preferences that persist between workflow runs (workflow scope), or maintain global feature flags accessible by all workflows (instance scope).
Properties
Name | Meaning |
---|---|
Scope | Defines where the data is stored: - Workflow: Data persists across workflow executions. - Instance: Data is shared across all workflows in the n8n instance. - Execution: Data is only available during the current workflow execution. |
Additional properties (not requested but relevant for understanding):
Name | Meaning |
---|---|
Operation | The action to perform: - Set: Store a value for a key. - Get: Retrieve a value by key. - Delete: Remove a value by key. - Clear: Remove all values in the selected scope. |
Key | The key to set, get, or delete. |
Value | The value to set for the key (supports JSON if enabled). |
Parse Value as JSON | Whether to parse the input value as JSON when setting. |
TTL (Seconds) | Time to live for the key in seconds; 0 means no expiration. |
Default Value | Value to return if the key does not exist when getting (supports JSON if enabled). |
Parse Default Value as JSON | Whether to parse the default value as JSON when getting. |
Output
The node outputs a JSON object containing the original input data merged with a kvsResult
field that describes the result of the operation performed:
- For set operations:
{ success: true, key: <key>, operation: "set" }
- For get operations: The retrieved value or the default value if the key does not exist.
- For delete operations:
{ success: <boolean>, key: <key>, operation: "delete" }
- For clear operations:
{ success: true, operation: "clear", scope: <scope> }
If an error occurs and "Continue On Fail" is enabled, the output will contain an error
field with the error message.
The node does not output binary data.
Dependencies
- No external services or APIs are required.
- The node relies on an internal singleton key-value engine instance to manage data storage.
- No special environment variables or credentials are needed.
Troubleshooting
- Could not determine workflow ID / execution ID: This error occurs if the node cannot identify the current workflow or execution context when using the "workflow" or "execution" scopes. Ensure the node is used within a valid workflow execution context.
- Invalid JSON: When parsing input values or default values as JSON, invalid JSON strings will cause errors. Verify that JSON inputs are correctly formatted.
- Unsupported operation: If an unsupported operation is specified, the node will throw an error. Use only the supported operations: set, get, delete, clear.
- Key missing: For operations requiring a key (set, get, delete), ensure the key property is provided and not empty.