Overview
This node, named "Redis Manipulate Cache," allows partial manipulation of existing data stored in a Redis database. It is designed to update or modify specific parts of JSON objects or hashes stored under Redis keys without replacing the entire value. This is particularly useful when working with complex cached data structures where only certain fields or array elements need to be changed.
Common scenarios include:
- Updating user profile information stored as JSON in Redis.
- Appending new items to arrays within JSON objects cached in Redis.
- Modifying individual fields in Redis hashes.
- Removing items from arrays inside JSON objects in Redis.
For example, you might use this node to append a new address to a user's list of addresses stored as a JSON array in Redis, or update a single field like "status" in a hash representing session data.
Properties
| Name | Meaning |
|---|---|
| Key | The Redis key containing the data to manipulate (e.g., user:123:profile). |
| Field Path | The path to the field to update inside the JSON object, using dot notation for nested fields (e.g., user.name or items[0].title). Required for JSON operations. |
| New Value | The new value to set for the specified field or to append to an array. Accepts valid JSON strings if needed. |
| Preserve TTL | Boolean flag indicating whether to keep the original expiration time (TTL) of the Redis key after modification. Defaults to true. |
Notes on Operation-Specific Properties
- For the Append to JSON Array operation, the relevant properties are:
- Key
- Field Path
- New Value
- Preserve TTL
Output
The node outputs an array of JSON objects, each corresponding to one input item processed. Each output object contains:
key: The Redis key that was manipulated.operation: The operation performed (appendJsonArrayin this case).success: A boolean indicating if the operation succeeded.result: The updated JSON object after the append operation.preservedTtl: The remaining TTL (time to live) of the Redis key if preserved; otherwise, null.timestamp: ISO string timestamp of when the operation was performed.
If the node manipulates binary data (not applicable here), it would summarize its meaning, but this node works exclusively with JSON and hash data in Redis.
Dependencies
- Requires a Redis server accessible with proper credentials (host, port, optional username/password, TLS).
- Needs an API key credential or equivalent authentication configured in n8n to connect securely to Redis.
- Uses a Redis connection utility internally to perform commands such as
get,set,hset,hgetall,exists,ttl, andexpire.
Troubleshooting
Common Issues
- Key does not exist: If the specified Redis key does not exist, the node throws an error indicating the key was not found.
- Invalid JSON: When parsing or manipulating JSON data, invalid JSON strings in either the stored data or the new value can cause errors.
- Field path not found: If the specified field path does not exist in the JSON object during removal or update, an error is thrown.
- Field is not an array: For append or remove operations, if the target field is not an array, the node will throw an error.
Error Messages and Resolutions
"A chave \"<key>\" não existe no Redis"— The Redis key does not exist. Verify the key name and ensure the data is present."Dados não encontrados"— No data found at the key. Check if the key holds any data."Falha ao manipular array JSON: <message>"— Failed to manipulate JSON array. Ensure the field path points to a valid array and the new value is valid JSON if required."Falha ao manipular JSON: <message>"— Failed to manipulate JSON object. Validate JSON syntax and field paths."O campo \"<field>\" não é um array"— The targeted field is not an array. Confirm the data structure before appending or removing.