Builds the proxy's coordination Redis client from resolved connection params. Cluster-mode targets (explicit `startup_nodes` or the REDIS_CLUSTER_NODES env var) get a `RedisClusterCache`, so consumers that branch on cluster mode (e.g. the v3 rate limiter) take the cluster path;
(redis_params: Mapping[str, object])
| 5332 | |
| 5333 | |
| 5334 | def build_redis_usage_cache(redis_params: Mapping[str, object]) -> RedisCache: |
| 5335 | """ |
| 5336 | Builds the proxy's coordination Redis client from resolved connection |
| 5337 | params. Cluster-mode targets (explicit `startup_nodes` or the |
| 5338 | REDIS_CLUSTER_NODES env var) get a `RedisClusterCache`, so consumers that |
| 5339 | branch on cluster mode (e.g. the v3 rate limiter) take the cluster path; |
| 5340 | everything else (host/url/sentinel) gets a plain `RedisCache`. |
| 5341 | """ |
| 5342 | startup_nodes = redis_params.get("startup_nodes") |
| 5343 | if startup_nodes is None: |
| 5344 | env_cluster_nodes: Final = get_secret_str("REDIS_CLUSTER_NODES") |
| 5345 | if env_cluster_nodes is not None: |
| 5346 | startup_nodes = _UNTYPED_VALUE.validate_python(json.loads(env_cluster_nodes)) |
| 5347 | non_node_params: Final = {key: value for key, value in redis_params.items() if key != "startup_nodes"} |
| 5348 | if startup_nodes: |
| 5349 | return RedisClusterCache(startup_nodes=startup_nodes, **non_node_params) |
| 5350 | return RedisCache(**non_node_params) |
| 5351 | |
| 5352 | |
| 5353 | _build_redis_usage_cache: Final = build_redis_usage_cache |
no test coverage detected