Redis集群与数据库的索引有何关系?

The code below is written in Go, but the problem itself relates to Redis.

Previously our code looked like the following:

c := redis.NewClient(
    &redis.Options{
        Addr: addr, 
        Password: pass, 
        DB: db,
    },
) 

But it was refactored to:

clusterSlots := func() ([]redis.ClusterSlot, error) {
    slots := []redis.ClusterSlot{
        {
            Start: 0,
            End:   16383,
            Nodes: []redis.ClusterNode{{
                    Addr: masterAddr,
                }, {
                    Addr: slaveAddr, 
                }},
        },
    }
    return slots, nil
}

rediscli := redis.NewClusterClient(&redis.ClusterOptions{
    ClusterSlots:  clusterSlots,
    RouteRandomly: true,
    Password:      pass,
})

And due to my level of understanding the overall Redis ideas, I don't quite understand, how does cluster relate to DB. Will it look through each of DB, with the index of zero nor any of variants?

Unfortunately, I have not enough time to dive in deeply.

dsfdsf48652
dsfdsf48652 非常感谢。现在很清楚
一年多之前 回复
dsgdg54ef4365
dsgdg54ef4365 群集不是选项。Redis集群和多个数据库也是解决2个完全不同问题的解决方案。
一年多之前 回复
douluhaikao93943
douluhaikao93943 这是否意味着,如果我想连接到DB1、2等集群,则不行吗?
一年多之前 回复
dongwei1954
dongwei1954 RedisCluster不支持多个数据库。只有一个数据库,即db0。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐