Overview
This node allows partial manipulation of existing data stored in a Redis cache. It is useful when you want to update or modify specific parts of JSON objects or hashes stored in Redis without overwriting the entire value. Common scenarios include updating user profiles, appending or removing items from JSON arrays, or modifying hash fields in Redis.
For example, you can:
- Remove an item from a JSON array inside a cached object.
- Update a nested field within a JSON object stored in Redis.
- Preserve the original expiration time (TTL) of the cached data while making modifications.
This granular control helps maintain data integrity and reduces the need for full data replacement.
Properties
| Name | Meaning |
|---|---|
| Key | The Redis key containing the data to be manipulated (e.g., user:123:profile). |
| Field Path | The path to the JSON field to manipulate, using dot notation for nested fields (e.g., items[0].title). Required for JSON operations including removal from JSON array. |
| Preserve TTL | Boolean flag indicating whether to keep the original expiration time of the Redis key after modification (true or false). |
Output
The node outputs a JSON object with the following structure:
{
"key": "string", // The Redis key that was manipulated
"operation": "string", // The operation performed, e.g., "removeJsonArray"
"success": true, // Boolean indicating if the operation succeeded
"result": { // The updated data after manipulation (JSON object or hash)
// Updated Redis data structure
},
"preservedTtl": 3600, // The preserved TTL in seconds if applicable, otherwise null
"timestamp": "2024-06-01T12:00:00.000Z" // ISO timestamp of when the operation occurred
}
If the node manipulates JSON data, the result contains the updated JSON object. For hash updates, it contains the updated hash fields.
The node does not output binary data.
Dependencies
- Requires a Redis server connection configured via credentials providing host, port, database number, username, password, and optional TLS settings.
- Uses a Redis client library internally to connect and perform commands.
- The node expects valid JSON strings stored at the specified keys for JSON operations.
- Proper Redis permissions are required to read, write, and modify keys.
Troubleshooting
- Key does not exist: If the specified Redis key does not exist, the node throws an error
"A chave \"<key>\" não existe no Redis". Ensure the key exists before running the node. - Data not found or invalid JSON: Errors like
"Dados não encontrados"or"Falha ao manipular JSON"indicate missing or malformed JSON data at the key. Verify the stored data is valid JSON. - Field path errors: If the specified field path does not exist or is not an array when expected, errors such as
"Caminho \"<fieldPath>\" não encontrado"or"O campo \"<field>\" não é um array"occur. Double-check the field path syntax and data structure. - Preserve TTL issues: If preserving TTL is enabled but the key has no expiration, TTL preservation will have no effect.
- General Redis errors: Connection or permission issues may cause failures. Confirm Redis credentials and network accessibility.