|
| 1 | +<!-- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + contributor license agreements. See the NOTICE file distributed with |
| 4 | + this work for additional information regarding copyright ownership. |
| 5 | + The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + (the "License"); you may not use this file except in compliance with |
| 7 | + the License. You may obtain a copy of the License at |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + Unless required by applicable law or agreed to in writing, software |
| 10 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + See the License for the specific language governing permissions and |
| 13 | + limitations under the License. |
| 14 | +--> |
| 15 | + |
| 16 | +# RedisDistributedMapCacheClientService |
| 17 | + |
| 18 | +## Redis Enterprise Software and Redis Cloud |
| 19 | + |
| 20 | +Configure a `RedisConnectionPoolService` and select it as the **Redis Connection Pool** for this service. |
| 21 | + |
| 22 | +| Connection pool property | Value | |
| 23 | +|---|---| |
| 24 | +| **Redis Mode** | `Standalone` for a database endpoint that routes commands through the Redis proxy, including sharded databases. Select `Cluster` only if the endpoint exposes the Redis Cluster API and its advertised nodes are reachable from NiFi. | |
| 25 | +| **Connection String** | The database endpoint as `hostname:port`. Use the database endpoint, not a management console or REST API endpoint. Do not include a `redis://` or `rediss://` scheme. | |
| 26 | +| **Database Index** | `0`. Redis Enterprise Software and Redis Cloud identify databases by endpoint. | |
| 27 | +| **Username** | The database ACL user, or `default` when using the default user. | |
| 28 | +| **Password** | The database user's password, supplied through a sensitive parameter. | |
| 29 | +| **SSL Context Service** | Configure this when the database endpoint requires TLS. Trust the database CA, and supply a client certificate and private key when mutual TLS is required. | |
| 30 | + |
| 31 | +`Standalone` describes the client connection topology. It does not require an unsharded Redis server and does not |
| 32 | +disable the availability or sharding provided by the Redis database endpoint. In `Standalone` mode, NiFi connects to |
| 33 | +the database proxy, and the proxy routes each command to the shard that owns the key, across nodes when the database |
| 34 | +spans several. See [proxy policies](https://redis.io/docs/latest/operate/rs/databases/configure/proxy-policy/) and |
| 35 | +[Redis Cloud clustering](https://redis.io/docs/latest/operate/rc/databases/configuration/clustering/). |
| 36 | + |
| 37 | +`Cluster` mode uses the [OSS Cluster API](https://redis.io/docs/latest/operate/rs/clusters/optimize/oss-cluster-api/): |
| 38 | +the client discovers the hash slot topology, connects to the node that owns each key, and follows redirects. It can |
| 39 | +reduce forwarding inside the database, but it is optional and is not required to use a sharded or multi-node database. |
| 40 | + |
| 41 | +## Atomic Operations and Permissions |
| 42 | + |
| 43 | +Conditional insert and replace operations act on one key at a time. The get-and-insert and compare-and-set operations |
| 44 | +use `EVAL` with a single explicitly declared key, keeping the read, conditional write, and TTL update together on the |
| 45 | +server. `WATCH`, `MULTI`, and `EXEC` are not required. Scripts and values are binary safe. Existing keys, values, and |
| 46 | +raw-value revisions retain their format. |
| 47 | + |
| 48 | +The Redis user needs permission for `EVAL` and the commands executed by these scripts (`GET` and `SET`), as well as |
| 49 | +commands used by the cache operations the flow calls (including `EXISTS`, `DEL`, `MSET`, and `EXPIRE`). Configure key |
| 50 | +permissions for the serialized cache keys. A server configured to prohibit scripting cannot use this atomic cache |
| 51 | +service. |
| 52 | + |
| 53 | +TTL is applied when an entry is inserted or successfully replaced. A failed comparison or an insert against an |
| 54 | +existing key leaves the value and its expiration unchanged. A TTL of `0 secs` creates entries without expiration. |
| 55 | + |
| 56 | +## Upgrading from Earlier Versions |
| 57 | + |
| 58 | +Earlier versions implemented `getAndPutIfAbsent` and `replace` with `WATCH`, `MULTI`, and `EXEC`. Those operations |
| 59 | +now run as Lua scripts. Before upgrading, grant the Redis user permission for `EVAL`, `GET`, and `SET` on the |
| 60 | +serialized cache keys. A user that is allowed `WATCH`, `MULTI`, and `EXEC` but not `EVAL` fails these operations with |
| 61 | +a `NOPERM` error, and the cache entry is left unchanged. |
| 62 | + |
| 63 | +## Deployment Considerations |
| 64 | + |
| 65 | +Single-key atomicity applies at the endpoint executing the operation. Redis Active-Active replication does not provide |
| 66 | +a globally serialized compare-and-set across regions. Flows that require global coordination, such as duplicate |
| 67 | +detection or Wait/Notify, should use one authoritative database rather than independent writable Active-Active |
| 68 | +regions. |
| 69 | + |
| 70 | +Bulk `putAll` retains its existing `MSET` behavior; it does not promise a transaction across multiple hash slots. |
| 71 | +Follow the database's multi-key command restrictions and use a common hash tag when a deployment requires keys in one |
| 72 | +slot. |
0 commit comments