github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/processors/redis.md (about) 1 --- 2 title: redis 3 type: processor 4 status: stable 5 categories: ["Integration"] 6 --- 7 8 <!-- 9 THIS FILE IS AUTOGENERATED! 10 11 To make changes please edit the contents of: 12 lib/processor/redis.go 13 --> 14 15 import Tabs from '@theme/Tabs'; 16 import TabItem from '@theme/TabItem'; 17 18 19 Performs actions against Redis that aren't possible using a 20 [`cache`](/docs/components/processors/cache) processor. Actions are 21 performed for each message of a batch, where the contents are replaced with the 22 result. 23 24 25 <Tabs defaultValue="common" values={[ 26 { label: 'Common', value: 'common', }, 27 { label: 'Advanced', value: 'advanced', }, 28 ]}> 29 30 <TabItem value="common"> 31 32 ```yaml 33 # Common config fields, showing default values 34 label: "" 35 redis: 36 url: tcp://localhost:6379 37 operator: scard 38 key: "" 39 ``` 40 41 </TabItem> 42 <TabItem value="advanced"> 43 44 ```yaml 45 # All config fields, showing default values 46 label: "" 47 redis: 48 url: tcp://localhost:6379 49 kind: simple 50 master: "" 51 tls: 52 enabled: false 53 skip_cert_verify: false 54 enable_renegotiation: false 55 root_cas: "" 56 root_cas_file: "" 57 client_certs: [] 58 operator: scard 59 key: "" 60 retries: 3 61 retry_period: 500ms 62 parts: [] 63 ``` 64 65 </TabItem> 66 </Tabs> 67 68 ## Operators 69 70 ### `keys` 71 72 Returns an array of strings containing all the keys that match the pattern specified by the `key` field. 73 74 ### `scard` 75 76 Returns the cardinality of a set, or `0` if the key does not exist. 77 78 ### `sadd` 79 80 Adds a new member to a set. Returns `1` if the member was added. 81 82 ### `incrby` 83 84 Increments the number stored at `key` by the message content. If the 85 key does not exist, it is set to `0` before performing the operation. 86 Returns the value of `key` after the increment. 87 88 ## Examples 89 90 <Tabs defaultValue="Querying Cardinality" values={[ 91 { label: 'Querying Cardinality', value: 'Querying Cardinality', }, 92 { label: 'Running Total', value: 'Running Total', }, 93 ]}> 94 95 <TabItem value="Querying Cardinality"> 96 97 98 If given payloads containing a metadata field `set_key` it's possible 99 to query and store the cardinality of the set for each message using a 100 [`branch` processor](/docs/components/processors/branch) in order to 101 augment rather than replace the message contents: 102 103 ```yaml 104 pipeline: 105 processors: 106 - branch: 107 processors: 108 - redis: 109 url: TODO 110 operator: scard 111 key: ${! meta("set_key") } 112 result_map: 'root.cardinality = this' 113 ``` 114 115 </TabItem> 116 <TabItem value="Running Total"> 117 118 119 If we have JSON data containing number of friends visited during covid 19: 120 121 ```json 122 {"name":"ash","month":"feb","year":2019,"friends_visited":10} 123 {"name":"ash","month":"apr","year":2019,"friends_visited":-2} 124 {"name":"bob","month":"feb","year":2019,"friends_visited":3} 125 {"name":"bob","month":"apr","year":2019,"friends_visited":1} 126 ``` 127 128 We can add a field that contains the running total number of friends visited: 129 130 ```json 131 {"name":"ash","month":"feb","year":2019,"friends_visited":10,"total":10} 132 {"name":"ash","month":"apr","year":2019,"friends_visited":-2,"total":8} 133 {"name":"bob","month":"feb","year":2019,"friends_visited":3,"total":3} 134 {"name":"bob","month":"apr","year":2019,"friends_visited":1,"total":4} 135 ``` 136 137 Using the `incrby` operator: 138 139 140 ```yaml 141 pipeline: 142 processors: 143 - branch: 144 request_map: | 145 root = this.friends_visited 146 meta name = this.name 147 processors: 148 - redis: 149 url: TODO 150 operator: incrby 151 key: ${! meta("name") } 152 result_map: 'root.total = this' 153 ``` 154 155 </TabItem> 156 </Tabs> 157 158 ## Fields 159 160 ### `url` 161 162 The URL of the target Redis server. Database is optional and is supplied as the URL path. The scheme `tcp` is equivalent to `redis`. 163 164 165 Type: `string` 166 Default: `"tcp://localhost:6379"` 167 168 ```yaml 169 # Examples 170 171 url: :6397 172 173 url: localhost:6397 174 175 url: redis://localhost:6379 176 177 url: redis://:foopassword@redisplace:6379 178 179 url: redis://localhost:6379/1 180 181 url: redis://localhost:6379/1,redis://localhost:6380/1 182 ``` 183 184 ### `kind` 185 186 Specifies a simple, cluster-aware, or failover-aware redis client. 187 188 189 Type: `string` 190 Default: `"simple"` 191 192 ```yaml 193 # Examples 194 195 kind: simple 196 197 kind: cluster 198 199 kind: failover 200 ``` 201 202 ### `master` 203 204 Name of the redis master when `kind` is `failover` 205 206 207 Type: `string` 208 Default: `""` 209 210 ```yaml 211 # Examples 212 213 master: mymaster 214 ``` 215 216 ### `tls` 217 218 Custom TLS settings can be used to override system defaults. 219 220 **Troubleshooting** 221 222 Some cloud hosted instances of Redis (such as Azure Cache) might need some hand holding in order to establish stable connections. Unfortunately, it is often the case that TLS issues will manifest as generic error messages such as "i/o timeout". If you're using TLS and are seeing connectivity problems consider setting `enable_renegotiation` to `true`, and ensuring that the server supports at least TLS version 1.2. 223 224 225 Type: `object` 226 227 ### `tls.enabled` 228 229 Whether custom TLS settings are enabled. 230 231 232 Type: `bool` 233 Default: `false` 234 235 ### `tls.skip_cert_verify` 236 237 Whether to skip server side certificate verification. 238 239 240 Type: `bool` 241 Default: `false` 242 243 ### `tls.enable_renegotiation` 244 245 Whether to allow the remote server to repeatedly request renegotiation. Enable this option if you're seeing the error message `local error: tls: no renegotiation`. 246 247 248 Type: `bool` 249 Default: `false` 250 Requires version 3.45.0 or newer 251 252 ### `tls.root_cas` 253 254 An optional root certificate authority to use. This is a string, representing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate. 255 256 257 Type: `string` 258 Default: `""` 259 260 ```yaml 261 # Examples 262 263 root_cas: |- 264 -----BEGIN CERTIFICATE----- 265 ... 266 -----END CERTIFICATE----- 267 ``` 268 269 ### `tls.root_cas_file` 270 271 An optional path of a root certificate authority file to use. This is a file, often with a .pem extension, containing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate. 272 273 274 Type: `string` 275 Default: `""` 276 277 ```yaml 278 # Examples 279 280 root_cas_file: ./root_cas.pem 281 ``` 282 283 ### `tls.client_certs` 284 285 A list of client certificates to use. For each certificate either the fields `cert` and `key`, or `cert_file` and `key_file` should be specified, but not both. 286 287 288 Type: `array` 289 Default: `[]` 290 291 ```yaml 292 # Examples 293 294 client_certs: 295 - cert: foo 296 key: bar 297 298 client_certs: 299 - cert_file: ./example.pem 300 key_file: ./example.key 301 ``` 302 303 ### `tls.client_certs[].cert` 304 305 A plain text certificate to use. 306 307 308 Type: `string` 309 Default: `""` 310 311 ### `tls.client_certs[].key` 312 313 A plain text certificate key to use. 314 315 316 Type: `string` 317 Default: `""` 318 319 ### `tls.client_certs[].cert_file` 320 321 The path to a certificate to use. 322 323 324 Type: `string` 325 Default: `""` 326 327 ### `tls.client_certs[].key_file` 328 329 The path of a certificate key to use. 330 331 332 Type: `string` 333 Default: `""` 334 335 ### `operator` 336 337 The [operator](#operators) to apply. 338 339 340 Type: `string` 341 Default: `"scard"` 342 Options: `scard`, `sadd`, `incrby`, `keys`. 343 344 ### `key` 345 346 A key to use for the target operator. 347 This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries). 348 349 350 Type: `string` 351 Default: `""` 352 353 ### `retries` 354 355 The maximum number of retries before abandoning a request. 356 357 358 Type: `int` 359 Default: `3` 360 361 ### `retry_period` 362 363 The time to wait before consecutive retry attempts. 364 365 366 Type: `string` 367 Default: `"500ms"` 368 369 ### `parts` 370 371 An optional array of message indexes of a batch that the processor should apply to. 372 If left empty all messages are processed. This field is only applicable when 373 batching messages [at the input level](/docs/configuration/batching). 374 375 Indexes can be negative, and if so the part will be selected from the end 376 counting backwards starting from -1. 377 378 379 Type: `array` 380 Default: `[]` 381 382