Actions41
- Append
- Blocking Pop Left
- Blocking Pop Right
- Delete
- Eval
- Exists
- Expire At
- Get
- Get Set
- Hash Exists
- Hash Get
- Hash Keys
- Hash Length
- Hash Set
- Hash Values
- Increment
- Info
- Keys
- List Length
- List Range
- Multi Get
- Multi Hash Get
- Multi Mix Get
- Multi Mix Set
- Multi Set
- Persist
- Pop
- Publish
- Push
- Scan
- Set
- Set Add
- Set Cardinality
- Set Is Member
- Set Remove
- Sorted Set Add
- Sorted Set Cardinality
- Sorted Set Range
- Sorted Set Remove
- String Length
- TTL
Overview
The "Redis Enhanced" node provides advanced interaction capabilities with a Redis database. It supports a wide range of Redis operations, including setting, getting, deleting keys, manipulating hashes, lists, sets, sorted sets, and executing Lua scripts. This node is beneficial in scenarios where you need to integrate Redis data storage or caching into your workflows, such as:
- Caching API responses or computation results.
- Managing session data or user state.
- Implementing distributed locks using atomic set-if-not-exists operations.
- Publishing messages to Redis channels for real-time notifications.
- Manipulating complex data structures like hashes, lists, and sorted sets.
For the Set operation specifically, it allows setting values of different Redis key types (string, hash, list, set) with options for conditional setting modes and expiration TTLs.
Properties
| Name | Meaning |
|---|---|
| Key | The name of the key to set in Redis. |
| Value | The value to write into the Redis key. For hashes, this can be JSON or key-value pairs depending on the "Value Is JSON" option. |
| Key Type | The type of the key to set. Options: - Automatic: Detects type based on data. - Hash: Data stored as a hash. - List: Data stored as a list. - Sets: Data stored as a set. - String: Data stored as a string. |
| Value Is JSON | (Only for Hash key type) Whether the value is JSON or simple key-value pairs. Defaults to true. |
| Expire | Whether to set an expiration timeout on the key. |
| TTL | Number of seconds before the key expires if "Expire" is enabled. Minimum value is 1 second. |
| Set Mode | Controls when the key should be set (only applies to String and Automatic key types): - Always Set: Set the key regardless of existence (default Redis SET behavior). - Set If Not Exists (NX): Set only if key does not exist (useful for atomic locks). - Set If Exists (XX): Set only if key already exists. |
Output
The output JSON contains the original input data merged with the result of the Redis set operation under the property redis_result. The exact content of redis_result depends on the Redis command's response but generally indicates success or details about the operation performed.
Example output structure:
{
"originalInput": { ... },
"redis_result": <result_of_set_operation>
}
No binary data output is produced by this operation.
Dependencies
- Requires a Redis server accessible via credentials configured in n8n.
- Needs an API key or authentication token credential for connecting to Redis.
- Uses the Redis client library internally to perform commands.
- No additional external services are required beyond Redis itself.
Troubleshooting
- Invalid JSON in Value: When setting a hash with "Value Is JSON" enabled, invalid JSON strings will cause errors. Ensure the JSON syntax is correct.
- TTL Errors: Setting TTL requires a positive integer; negative or zero values will cause failures.
- Set Mode Conflicts: Using NX or XX modes incorrectly may result in no key being set if conditions are not met. Verify the key existence state before choosing these modes.
- Connection Issues: Failure to connect to Redis usually indicates incorrect credentials or network issues. Check Redis server availability and credential correctness.
- Key Type Mismatch: If the actual Redis key type differs from the specified "Key Type," commands may fail or behave unexpectedly. Use "Automatic" to let the node detect the type or ensure the key type matches.