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. It allows users to get, set, update, delete, and manipulate data stored in Redis with enhanced capabilities such as automatic type detection, JSON parsing, and support for various Redis data types (strings, hashes, lists, sets, sorted sets).
This node is beneficial in scenarios where workflows need to integrate with Redis for caching, session management, real-time messaging, or data storage. For example, it can be used to:
- Retrieve the time-to-live (TTL) of a key to monitor cache expiration.
- Persist keys by removing their expiration.
- Set or update values with optional expiration times.
- Perform atomic increments on counters.
- 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 managing expiring data.
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 to get the TTL or persist the expiration (required). |
Note: The provided properties are specific to the "TTL" and "Persist" operations under the default resource.
Output
The output JSON structure for the TTL operation contains:
{
"key": "the queried key name",
"ttl": "time to live in seconds (integer)"
}
key: The Redis key whose TTL was requested.ttl: The number of seconds until the key expires. A value of -1 means the key exists but has no expiration, and -2 means the key does not exist.
For the Persist operation, the output JSON is:
{
"key": "the queried key name",
"persisted": "integer indicating if expiration was removed (1) or not (0)"
}
If the node supports binary data output in other operations, it would represent raw binary content from Redis keys, but TTL operation outputs only 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 internally to connect and execute commands.
- No additional external services are required beyond Redis itself.
Troubleshooting
Common Issues:
- Connection failures due to incorrect Redis credentials or network issues.
- Requesting TTL for a non-existent key returns -2; ensure the key exists.
- If the key has no expiration, TTL returns -1, which might be unexpected if expiration is assumed.
- JSON parsing errors may occur if values expected as JSON are malformed (relevant for other operations).
Error Messages:
"Invalid JSON in value": Occurs if a value marked as JSON cannot be parsed. Fix by ensuring valid JSON input.- Connection errors: Check Redis credentials and network connectivity.
"Key-value pairs must be even number of arguments": When setting multiple keys, ensure pairs are correctly formatted.
To handle errors gracefully, enable the "Continue On Fail" option in the node settings.
Links and References
- Redis Official Documentation
- Redis TTL Command
- Redis Persist Command
- n8n Redis Node Documentation (for general Redis usage in n8n)