Redis Enhanced icon

Redis Enhanced

Get, send and update data in Redis with enhanced operations

Overview

The node "Redis Enhanced" provides advanced interaction capabilities with a Redis database. It supports a wide range of Redis operations, including setting, getting, deleting keys, manipulating lists, sets, hashes, sorted sets, and executing Lua scripts. The "Set" operation specifically allows users to write data into Redis keys with flexible options for key types, conditional set modes, expiration times, and JSON handling.

This node is beneficial in scenarios where workflows need to store or update data in Redis dynamically, such as caching results, managing session data, implementing distributed locks, or maintaining real-time data structures like lists and sets.

Practical example:

  • Storing user session information as a hash with JSON content and setting an expiration time to automatically clear sessions after inactivity.
  • Conditionally setting a string key only if it does not exist to implement atomic locking mechanisms.

Properties

Name Meaning
Key The name of the Redis key to set.
Value The value to write into the Redis key.
Key Type The type of the Redis 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 key-value pairs. If true, the value is parsed as JSON before storing.
Expire Whether to set a timeout (expiration) on the key.
TTL Number of seconds before the key expires (only applicable if Expire is true).
Set Mode Controls when the key should be set (only for String or Automatic key types). Options:
- Always Set: Set the key regardless of existence.
- Set If Not Exists (NX): Set only if the key does not exist.
- Set If Exists (XX): Set only if the key already exists.

Output

The output is an array of JSON objects representing the result of the set operation for each input item. Each output JSON object includes:

  • The original input data merged with a new property redis_result that contains the result returned by the Redis client for the set operation. This result typically indicates success or details about the operation performed.

For example, the output JSON might look like:

{
  "originalInputProperty1": "...",
  "redis_result": "OK"
}

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 the Redis instance.

Troubleshooting

  • Common issues:

    • Connection failures due to incorrect Redis credentials or network issues.
    • Invalid key or value formats, especially when using JSON parsing for hash values.
    • Setting TTL without enabling expiration may cause confusion as keys won't expire.
    • Using incompatible set modes with certain key types can lead to unexpected behavior.
  • Error messages:

    • Errors from Redis commands (e.g., syntax errors, wrong data types) will be thrown and can stop execution unless "Continue On Fail" is enabled.
    • If key-value pairs for multi-set operations are uneven, an error is raised.
    • JSON parsing errors when valueIsJSON is true but the value is not valid JSON.
  • Resolutions:

    • Verify Redis credentials and connectivity.
    • Ensure correct data format according to the selected key type.
    • Enable expiration explicitly if TTL is set.
    • Use appropriate set mode for your use case (e.g., NX for locks).

Links and References

Discussion