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.