Redis Enhanced icon

Redis Enhanced

Get, send and update data in Redis with enhanced operations

Overview

This node, named "Redis Enhanced," provides a comprehensive interface to interact with a Redis database. It supports a wide range of Redis operations such as setting and getting keys, managing lists, sets, sorted sets, hashes, executing Lua scripts, and more. The node is useful for workflows that require caching, messaging, data storage, or real-time data manipulation using Redis.

Common scenarios include:

  • Caching API responses or computed data.
  • Managing queues or lists for asynchronous processing.
  • Publishing and subscribing to messages via Redis channels.
  • Performing atomic increments or conditional key updates.
  • Executing custom Lua scripts for complex Redis operations.

For example, you could use this node to persist a session token in Redis, increment counters atomically, or remove expiration from a key to make it persistent.

Properties

Name Meaning
Operation The Redis operation to perform. Options include: Append, Blocking Pop Left/Right, Delete, Exists, Expire At, Get, Get Set, Hash Exists, Hash Keys, Hash Length, Hash Values, Increment, Info, Keys, List Length, Multi Get, 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, etc.
Key The name of the Redis key to operate on (required for many operations).
Value The value to set or append to a key (used in set, append, getset operations).
Value Is JSON Boolean indicating if the value is JSON or key-value pairs (used when key type is hash).
Key Type The type of the key's data structure: Automatic, Hash, List, Sets, or String.
Expire Boolean to indicate whether to set a timeout on the key (used in set, incr operations).
TTL Time-to-live in seconds before the key expires (used with expire option).
Set Mode Controls when the key should be set: Always, Only if Not Exists (NX), or Only if Exists (XX).
PropertyName The property name in the output JSON where retrieved data will be stored (supports dot notation).
Channel The Redis channel name for publish operation.
MessageData The message data to publish or push to a list.
List The name of the Redis list for push, pop, blpop, brpop, llen operations.
Tail Boolean indicating whether to push/pop from the end (tail) of the list.
Timeout Timeout in seconds for blocking pop operations (blpop, brpop).
Keys Space-separated list of keys for exists, mget, eval operations.
KeyValuePairs Space-separated key-value pairs for multi-set (mset) operation.
Cursor Cursor position for scan operation (0 to start).
Pattern Pattern to match keys against in scan operation.
Count Approximate number of keys to return in scan operation.
Timestamp Unix timestamp for expireat operation.
ScoreMembers Space-separated score-member pairs for sorted set add (zadd) operation.
Start, Stop Start and stop indices for sorted set range (zrange) operation.
WithScores Boolean to include scores in zrange results.
Set, Members, Member Names and members for set operations (sadd, srem, sismember, scard).
Hash, Field Names for hash operations (hlen, hkeys, hvals, hexists).
Script, Args Lua script and arguments for eval operation.

Output

The node outputs an array of items, each containing a json object with the result of the Redis operation performed. The structure of the json depends on the operation:

  • For key retrieval operations (get, mget, hkeys, etc.), the output contains the requested values mapped by key or field names.
  • For mutation operations (set, incr, delete, etc.), the output includes confirmation details like new length, added/removed counts, or status booleans.
  • For list operations (push, pop, blpop, brpop), the output includes the popped or pushed elements and list names.
  • For sorted set operations (zadd, zrange, zrem), the output includes members, scores, and counts.
  • For info operation, the output is a parsed object representing Redis server information.
  • For persist operation, output indicates whether the expiration was removed successfully.
  • For eval operation, the output contains the result of the Lua script execution.

If binary data were involved (not indicated here), it would be summarized accordingly, but this node primarily deals with string and structured JSON data.

Dependencies

  • Requires a Redis server accessible via credentials configured in n8n.
  • Needs an API key or authentication token for Redis connection (configured as credentials in n8n).
  • Uses the Redis client library and lodash for internal operations.
  • No additional external services are required beyond Redis itself.

Troubleshooting

  • Connection errors: Ensure Redis credentials are correct and the Redis server is reachable.
  • Invalid key or field names: Provide valid Redis keys and fields; empty or malformed keys may cause errors.
  • Mismatched key-value pairs in multi-set: The mset operation requires an even number of arguments; otherwise, an error is thrown.
  • Timeouts in blocking pop operations: If no element is available within the specified timeout, the output will have null values.
  • JSON parsing errors: When retrieving or popping data, if the value is not valid JSON but expected to be, parsing will fail silently and return raw strings.
  • Unsupported operations: Using an operation not listed or supported will cause errors.
  • Continue on Fail: If enabled, errors per item will be returned in the output instead of stopping execution.

Links and References

Discussion