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. It allows users to get, set, delete, and manipulate data stored in Redis keys, including strings, hashes, lists, sets, and sorted sets. The node supports advanced features such as executing Lua scripts, scanning keys incrementally, managing key expiration, and publishing messages to Redis channels.

This node is beneficial in scenarios where workflows require caching, session management, real-time messaging, or any form of fast key-value storage interaction. For example, it can be used to:

  • Retrieve the time-to-live (TTL) of a specific Redis key to monitor cache expiry.
  • Persist a key by removing its expiration.
  • Manage list data structures by pushing or popping elements.
  • Execute custom Lua scripts for complex atomic operations.
  • Publish messages to Redis channels for event-driven architectures.

Specifically, the TTL operation fetches the remaining lifetime (in seconds) of a given key, which is useful for monitoring cache validity or implementing conditional logic based on key expiration.

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 for which the TTL (time to live) is requested or persistence is managed.

Output

The output JSON object for the TTL operation contains:

  • key: The name of the Redis key queried.
  • ttl: The time to live of the key in seconds. A value of -1 typically means the key exists but has no associated expiration, and -2 means the key does not exist.

Example output JSON:

{
  "key": "myCacheKey",
  "ttl": 120
}

If the node performs other operations, the output structure varies accordingly, but for TTL specifically, it returns the key and its TTL value.

Dependencies

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

Troubleshooting

  • Common issues:
    • Connection failures due to incorrect Redis credentials or network issues.
    • Querying TTL for a non-existent key will return -2; ensure the key exists before querying.
    • Permissions errors if the Redis user lacks rights to perform certain commands.
  • Error messages:
    • Errors during connection or command execution are thrown as node operation errors.
    • If "Continue On Fail" is enabled, errors for individual items are returned in the output JSON under an error property.
  • Resolutions:
    • Verify Redis credentials and network connectivity.
    • Confirm the key exists before requesting TTL.
    • Check Redis user permissions and roles.

Links and References

Discussion