I am attempting to use the Ruby Redis client redis-rb to connect to an Azure Redis Cache configured for clustering.
What I've tried:
I have used this related question to successfully connect to a non-clustered Azure Redis Cache. I can also use this to connect to a clustered Azure Redis Cache, which correctly reports MOVED
when I attempt to get or set keys:
Redis::CommandError (MOVED 1234 address_here:port_here)
I have seen this documentation for creating the connection with cluster
:
Nodes can be passed to the client as an array of connection URLs.
nodes = (7000..7005).map { |port| "redis://127.0.0.1:#{port}" } redis = Redis.new(cluster: nodes)
You can also specify the options as a Hash. The options are the same as for a single server connection.
(7000..7005).map { |port| { host: '127.0.0.1', port: port } }
I have used these examples to build an example against the single available DNS endpoint that fails with the following error:
irb(main):024:0> client = Redis.new(cluster: ["redis://my-redis-cluster.redis.cache.windows.net:6379"])
...
Redis::CannotConnectError (Redis client could not connect to any cluster nodes)
I've tried each variant of this listed in the documentation, with the same results.
Problem:
Azure Cache for Redis exposes the clustered nodes on a single DNS endpoint, while this redis-rb cluster parameter seems to expect a collection of known node endpoints.
Is it possible to use this library to connect to a clustered Azure Redis Cache? And if so, what would a reproducible example of this look like? If it is not possible with redis-rb, but is possible with another Ruby Redis client, I would also be interested in that solution.