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 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:
- Paginating through all keys in a Redis instance when you want to avoid performance issues caused by commands like
KEYSthat return all keys at once. - Searching for keys matching a specific pattern incrementally.
- Building applications that need to process or analyze subsets of keys in batches.
For example, you might use the Scan operation to:
- Retrieve all keys starting with "user:" in batches of 100 to process user-related data.
- Implement a background job that periodically scans and cleans up expired or obsolete keys.
Properties
| Name | Meaning |
|---|---|
| Cursor | Cursor position for scanning; start with 0 to begin a new scan session |
| 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 (batch size) |
Output
The output JSON object from the Scan operation contains two fields:
cursor: A number representing the next cursor position to be used for subsequent scan calls. When this value returns to 0, the scan is complete.keys: An array of strings containing the keys matched in the current scan batch according to the specified pattern.
Example output:
{
"cursor": 1234,
"keys": ["user:1", "user:2", "session:abc"]
}
This structure enables iterative scanning by passing the returned cursor back into the node to continue fetching keys until the cursor resets to 0.
Dependencies
- Requires a Redis server accessible via credentials configured in n8n.
- Needs an API key credential or connection details for Redis authentication.
- Uses the official Redis client library internally.
- No additional external services are required.
Troubleshooting
- Empty keys array but non-zero cursor: This can happen if no keys match the pattern in the current scan batch. Continue scanning with the returned cursor until it reaches 0.
- Cursor never returns to 0: Ensure the Redis server is stable and not under heavy load. Also, verify that the pattern and count parameters are set correctly.
- Connection errors: Verify Redis credentials and network connectivity.
- Invalid pattern syntax: Use valid glob-style patterns supported by Redis SCAN command.
Links and References
- Redis SCAN command documentation
- Redis official website
- n8n Redis Enhanced node documentation (if available) (Note: link is illustrative)