redis
Performs actions against Redis that aren't possible using a cache processor. Actions are
performed for each message and the message contents are replaced with the result. In order to merge the result into the original message compose this processor within a branch processor.
- Common
- Advanced
# Common config fields, showing default values
label: ""
redis:
url: redis://:6397 # No default (required)
command: scard # No default (optional)
args_mapping: root = [ this.key ] # No default (optional)
# All config fields, showing default values
label: ""
redis:
url: redis://:6397 # No default (required)
kind: simple
master: ""
tls:
enabled: false
skip_cert_verify: false
enable_renegotiation: false
root_cas: ""
root_cas_file: ""
client_certs: []
command: scard # No default (optional)
args_mapping: root = [ this.key ] # No default (optional)
retries: 3
retry_period: 500ms
Examples
- Querying Cardinality
- Running Total
If given payloads containing a metadata field set_key it's possible to query and store the cardinality of the set for each message using a branch processor in order to augment rather than replace the message contents:
pipeline:
processors:
- branch:
processors:
- redis:
url: TODO
command: scard
args_mapping: 'root = [ metadata("set_key") ]'
result_map: 'root.cardinality = this'
If we have JSON data containing number of friends visited during covid 19:
{"name":"ash","month":"feb","year":2019,"friends_visited":10}
{"name":"ash","month":"apr","year":2019,"friends_visited":-2}
{"name":"bob","month":"feb","year":2019,"friends_visited":3}
{"name":"bob","month":"apr","year":2019,"friends_visited":1}
We can add a field that contains the running total number of friends visited:
{"name":"ash","month":"feb","year":2019,"friends_visited":10,"total":10}
{"name":"ash","month":"apr","year":2019,"friends_visited":-2,"total":8}
{"name":"bob","month":"feb","year":2019,"friends_visited":3,"total":3}
{"name":"bob","month":"apr","year":2019,"friends_visited":1,"total":4}
Using the incrby command:
pipeline:
processors:
- branch:
processors:
- redis:
url: TODO
command: incrby
args_mapping: 'root = [ this.name, this.friends_visited ]'
result_map: 'root.total = this'