Overview
This node implements a simple in-memory key-value datastore within the n8n instance. It allows users to store, retrieve, and clear data by keys during workflow execution, enabling data sharing between different parts of a workflow or across multiple executions.
Common scenarios where this node is beneficial include:
- Temporarily saving intermediate results for reuse later in the workflow.
- Sharing configuration or state information without external databases.
- Clearing stored data when resetting workflow states.
For example, you can use the "Set" operation to save user input or API response data under a specific key, then use the "Get" operation later to retrieve that data. The "Clear" and "Clear All" operations help manage stored data lifecycle.
Properties
| Name | Meaning |
|---|---|
| Output for Set/Clear | Defines what the node outputs after performing a Set or Clear operation. Options: |
| - Pass Through: Outputs the same data it received as input in full. | |
| - Output Key: Outputs only status, operation, and key. | |
| - Output Value: Outputs only status, operation, and saved value. | |
| - Output Key-Value: Outputs only the key-value pair. |
Note: This property applies to the "set", "clear", and "clearAll" operations.
Output
The node outputs an array of items with JSON data structured depending on the operation and the selected output option:
Set Operation:
- If multiple items are set with the same key and JSON data type, the stored value is an array of parsed JSON objects.
- Output can be:
- Full input items (Pass Through).
- Status object with success flag, operation name, key, and optionally item count.
- Status with saved value.
- Only the key-value pair.
Get Operation:
- Outputs items containing:
key: the requested key.value: the stored value (can be any type, including arrays).found: boolean indicating if the key was found.
- Outputs items containing:
Clear Operation:
- Outputs status with success flag, operation name, key, and whether the key was cleared.
- Optionally includes the cleared value if requested.
Clear All Operation:
- Outputs status with success flag and operation name.
If binary data were supported, it would be summarized here, but this node only handles JSON data.
Dependencies
- No external services or APIs are required.
- The node uses an internal static Map object (
memoryStore) to hold data in memory. - No special environment variables or credentials are needed.
Troubleshooting
- Missing Key Name: For "Set", "Get", and "Clear" operations, the node requires a key name. Omitting it will throw an error indicating the key name is required.
- Invalid JSON Input: When setting values with JSON data type, invalid JSON strings cause errors specifying which item failed and why.
- Unknown Data Type: If a data type other than "string" or "json" is provided, the node throws an error about unknown data type.
- Data Persistence: Since the datastore is in-memory, all stored data is lost when the n8n instance restarts. Users expecting persistent storage should consider external databases.
- Output Configuration: Selecting incompatible output options may lead to unexpected output formats; ensure the "Output for Set/Clear" property matches your needs.
Links and References
- n8n Documentation – General resource for building workflows and using nodes.
- JavaScript Map Object – Explanation of the underlying data structure used for storage.