Redis Enhanced icon

Redis Enhanced

Get, send and update data in Redis with enhanced operations

Overview

The node "Redis Enhanced" provides a comprehensive interface to interact with a Redis database, supporting a wide range of Redis operations. The "Scan" operation specifically allows incremental iteration over keys in the Redis store, which is useful for safely retrieving large sets of keys without blocking the server or client.

Common scenarios where the Scan operation is beneficial include:

  • Efficiently listing keys matching a pattern in a production environment.
  • Paginating through keys when the total number is large.
  • Avoiding performance issues caused by commands that return all keys at once.

For example, you can use the Scan operation to retrieve batches of keys matching a certain prefix, processing them incrementally in your workflow.

Properties

Name Meaning
Cursor Cursor position for scanning; start with 0 to begin a new scan and use returned cursor to continue.
Pattern Pattern to match keys against, e.g., * for all keys or user:* for keys starting with "user:".
Count Approximate number of keys to return per scan call; controls batch size.
Value Is JSON (Shown only if key type is "hash") Whether the value stored is JSON or key-value pairs.

Output

The output JSON object from the Scan operation contains two fields:

  • cursor: A number representing the next cursor position to be used for continuing the scan. When this is 0, the scan is complete.
  • keys: An array of strings containing the keys matched in the current scan batch.

Example output:

{
  "cursor": 1234,
  "keys": ["key1", "key2", "key3"]
}

This structure allows iterative fetching of keys in manageable chunks.

Dependencies

  • Requires a Redis instance accessible via credentials configured in n8n.
  • Needs an API key credential or connection details for Redis authentication.
  • Uses the Redis client library internally to perform operations.

Troubleshooting

  • Empty keys array but non-zero cursor: This means the scan is ongoing but no keys matched in this batch; continue scanning using the returned cursor.
  • Cursor never returns to 0: Ensure the cursor parameter is correctly passed between executions; incorrect cursor usage can cause infinite loops.
  • Connection errors: Verify Redis credentials and network connectivity.
  • Pattern syntax issues: Use valid glob-style patterns (*, ?, [abc]) for matching keys.
  • Count too high: Setting count very high may impact performance; adjust to reasonable batch sizes.

Links and References

Discussion