Redis Enhanced icon

Redis Enhanced

Get, send and update data in Redis with enhanced operations

Overview

The "Redis Enhanced" node provides a comprehensive interface to interact with a Redis database, supporting a wide range of operations such as setting, getting, deleting keys, managing lists, sets, sorted sets, hashes, and executing Lua scripts. It is designed for scenarios where users need to manipulate Redis data structures programmatically within an n8n workflow.

This node is beneficial when you want to:

  • Store or retrieve cached data.
  • Manage queues using Redis lists.
  • Perform atomic increments or conditional key updates.
  • Publish messages to Redis channels for pub/sub patterns.
  • Execute complex Lua scripts on the Redis server.
  • Manage expiration and persistence of keys.

Example use cases:

  • Persisting session data in Redis.
  • Implementing rate limiting by incrementing counters.
  • Managing task queues with push/pop list operations.
  • Publishing notifications to subscribers via Redis channels.
  • Removing expiration from keys to make them persistent.

Properties

Name Meaning
Value Is JSON Whether the value is JSON or key-value pairs (only shown when key type is "hash").
Key Name of the key to operate on (required for operations like persist, ttl, delete, etc.).

Note: The node supports many other properties depending on the selected operation, such as:

  • Operation: The Redis command to execute (e.g., persist, set, get, delete).
  • Property Name: The name of the property to write received data to (supports dot notation).
  • Key Type: The data type of the key (automatic, hash, list, sets, string).
  • Expire: Whether to set a timeout on the key.
  • TTL: Time-to-live in seconds for key expiration.
  • Set Mode: Controls conditional setting behavior (always, if not exists, if exists).
  • Channel: For publish operation, the channel name.
  • Message Data: Data to publish or push.
  • List, Set, Sorted Set, Hash: Names of respective Redis data structures.
  • Members, Score-Member Pairs: Elements to add/remove in sets or sorted sets.
  • Script, Keys, Arguments: For executing Lua scripts.

Output

The output is an array of JSON objects representing the results of the executed Redis commands for each input item. The structure varies depending on the operation:

  • For key retrieval operations (get, mget), the output contains the key values mapped to property names.
  • For mutation operations (set, delete, persist), the output includes confirmation details such as success flags or new lengths.
  • For list/set/sorted set operations, outputs include counts, members, or affected elements.
  • For eval (Lua script execution), the output contains the result of the script.
  • For blocking pop operations (blpop, brpop), the output includes the popped element and the list name.
  • For info, the output is a parsed object of Redis server information.

If binary data were supported, it would be summarized accordingly, but this node primarily deals with JSON and string data.

Dependencies

  • Requires a Redis server connection configured via credentials that provide necessary authentication.
  • Uses the official Redis client library for Node.js.
  • No additional environment variables are explicitly required beyond the Redis credentials.

Troubleshooting

  • Connection errors: Ensure the Redis server is reachable and credentials are correct.
  • Key-value pairs must be even number of arguments: When using multi-set operations, ensure keys and values are paired correctly.
  • Timeouts on blocking pop operations: If a timeout is set, the operation may return null if no element is available within the time.
  • Invalid Lua script: Syntax errors or runtime errors in Lua scripts will cause execution failure.
  • Unsupported key types: Using incorrect key types for certain operations may lead to errors.
  • To resolve errors, verify parameters, check Redis server logs, and ensure network connectivity.

Links and References

Discussion