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. The TTL operation specifically retrieves the time-to-live (expiration time) for a given key in Redis.

This node is beneficial in scenarios where you need to manage caching, session data, or any temporary data storage that requires expiration control. For example, you can use the TTL operation to monitor how long a cached item will remain valid before it expires, enabling workflows to refresh or invalidate cache entries proactively.

Properties

Name Meaning
Key Name of the key in Redis for which to get the time to live (TTL).

Note: The provided properties JSON includes "Value Is JSON" but it applies only when the key type is "hash" and is not relevant for the TTL operation.

Output

The output JSON object contains:

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

Example output:

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

This output allows downstream nodes or workflows to understand the remaining lifetime of a key in Redis.

Dependencies

  • Requires a Redis server connection configured via an API key credential or equivalent authentication method.
  • The node uses a Redis client library internally to communicate with the Redis instance.
  • Proper Redis credentials must be set up in n8n for this node to connect successfully.

Troubleshooting

  • Common issues:

    • Connection failures due to incorrect Redis credentials or network issues.
    • Querying TTL on a non-existent key returns -2; ensure the key exists before querying TTL.
    • Permissions issues if the Redis user does not have rights to query TTL.
  • Error messages:

    • Errors during connection or command execution will throw exceptions. If "Continue On Fail" is enabled, errors are returned in the output JSON under an error field.
    • Typical error: "Key does not exist" — occurs if the key is missing; verify the key name.
    • Timeout or network errors indicate connectivity problems; check Redis server availability and credentials.

Links and References

Discussion