Overview
This node stores data in a Redis cache with a configurable expiration time. It supports storing simple strings, JSON objects, or Redis hashes (key-value field sets). This is useful for caching frequently accessed data to improve application performance, session management, or sharing state between different parts of a workflow.
Practical examples:
- Caching user profile information keyed by user ID to reduce database load.
- Storing API response data temporarily to avoid repeated calls.
- Managing session tokens or temporary flags using Redis hashes.
Properties
Name | Meaning |
---|---|
Key | Unique key under which the data will be stored in Redis. Prefixes are recommended for organization. |
Data Type | Type of data to store: String (simple string), JSON (object serialized as JSON), or Hash (field-value pairs). |
Value | The value to store when Data Type is String or JSON . For JSON, must be valid JSON format. |
Hash Fields | When Data Type is Hash , a collection of fields and their values to store as a Redis hash. |
Expiration (seconds) | Time in seconds after which the cached data expires. Use 0 for no expiration. Examples: 3600 = 1 hour, 86400 = 1 day. |
Output
The node outputs an array of JSON objects, one per input item, each containing:
key
: The Redis key used.dataType
: The type of data stored (string
,json
, orhash
).success
: Boolean indicating if the storage operation succeeded.expiresIn
: Number of seconds until expiration or"never"
if no expiration was set.timestamp
: ISO timestamp of when the data was stored.
No binary output is produced.
Example output JSON for one item:
{
"key": "user:123:profile",
"dataType": "json",
"success": true,
"expiresIn": 3600,
"timestamp": "2024-06-01T12:00:00.000Z"
}
Dependencies
- Requires a Redis server connection configured via credentials including host, port, optional username, password, and TLS settings.
- Uses an internal Redis connection helper module to manage the connection.
- The node expects a valid Redis environment accessible from n8n.
Troubleshooting
- Invalid JSON error: When storing JSON data, the provided value must be valid JSON. If parsing fails, the node throws an error indicating invalid JSON.
- Missing hash fields: When using the Hash data type, at least one field-value pair must be provided; otherwise, an error is thrown.
- Connection errors: Issues connecting to Redis (wrong host, port, credentials, or network issues) will cause errors during execution.
- Expiration handling: Setting expiration to 0 disables expiry; ensure this is intentional to avoid stale cache entries.
- General errors: Any unexpected error during storage results in a generic error message with details.
To resolve errors:
- Validate JSON syntax before input.
- Provide at least one hash field when using Hash type.
- Verify Redis credentials and connectivity.
- Check expiration values for correctness.