In-Memory KVS icon

In-Memory KVS

Store and retrieve data in memory with different scopes

Overview

This node provides an in-memory key-value store (KVS) with different scopes for storing and retrieving data during workflow executions in n8n. It supports operations to set, get, delete, and clear key-value pairs within three distinct scopes:

  • Workflow: Data persists across multiple executions of the same workflow.
  • Instance: Data is shared globally across all workflows running on the same n8n instance.
  • Execution: Data is only available during the current workflow execution.

This node is useful when you want to temporarily or persistently store small pieces of data without relying on external databases or services. For example, you can cache API responses during a workflow run, share state between different workflows, or keep track of counters or flags that survive multiple executions.

Properties

Name Meaning
Operation The action to perform: Set, Get, Delete, or Clear key-value pairs.
Scope Where the data is stored: Workflow, Instance, or Execution.
Key The key name to set, get, or delete. Required for Set, Get, and Delete operations.
Value The value to set for the key (supports JSON). Required for Set operation.
Parse Value as JSON Whether to parse the input value as JSON before storing it (only for Set).
TTL (Seconds) Time to live in seconds for the key (0 means no expiration). Only for Set.
Default Value Default value to return if the key does not exist (supports JSON). Only for Get.
Parse Default Value as JSON Whether to parse the default value as JSON before returning it (only for Get).

Output

The node outputs a JSON object containing the original input data merged with a kvsResult field that holds the result of the operation performed. The structure varies by operation:

  • Set: { success: true, key: <key>, operation: "set" }
  • Get: The value associated with the key or the default value if the key does not exist.
  • Delete: { success: <boolean>, key: <key>, operation: "delete" }
  • Clear: { success: true, operation: "clear", scope: <scope> }

If an error occurs and the node is configured to continue on failure, the output will contain an error field describing the issue.

No binary data is output by this node.

Dependencies

  • This node uses an internal singleton engine to manage the key-value storage in memory.
  • No external services or API keys are required.
  • No special environment variables or n8n configurations are needed.

Troubleshooting

  • Could not determine workflow ID: This error occurs if the node cannot identify the current workflow's ID when using the workflow or execution scope. Ensure the node is used within a properly initialized workflow context.
  • Invalid JSON: When parsing 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, or clear.
  • Key is required: For operations that require a key (set, get, delete), ensure the key property is provided and not empty.

Links and References

Discussion