Search code examples
redisstackexchange.redisazure-redis-cache

How to determine whether connected Redis is a single node or cluster mode using StackExchange.Redis?


I only have Azure Redis cache hostname but no other information. Is there any way to tell whether this Redis host name has a Cluster of nodes or just a single node? I am using c# with stackExchange.Redis.


Solution

  • It is not feasible to judge only by Azure Redis cache hostname.

    You need at least hostname, groupname, and bearer token.

    You can create HttpClient in C# code and use rest api to query the value of shardCount. According to the value of shardCount, you can determine whether your azure redis cache has the cluster function enabled.

    If shardCount=1, then it is a single node. If it is greater than 1, it means that the cluster size function is enabled on the portal.

    Sample pic:

    On portal:

    enter image description here

    Test rest api online.

    enter image description here