duangaoe9401 2019-04-26 07:57
浏览 349

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
    • ¥15 CreateBitmapFromWicBitmap内存释放问题。
    • ¥30 win c++ socket
    • ¥30 CanMv K210开发板实现功能
    • ¥15 C# datagridview 栏位进度
    • ¥15 vue3页面el-table页面数据过多
    • ¥100 vue3中融入gRPC-web
    • ¥15 kali环境运行volatility分析android内存文件,缺profile
    • ¥15 写uniapp时遇到的问题
    • ¥15 vs 2008 安装遇到问题