Source File
shard_picker.go
Belonging Package
github.com/redis/go-redis/v9/internal/routing
package routingimport ()// ShardPicker chooses “one arbitrary shard” when the request_policy is// ReqDefault and the command has no keys.type ShardPicker interface {Next(total int) int // returns an index in [0,total)}// StaticShardPicker always returns the same shard index.type StaticShardPicker struct {index int}func ( int) *StaticShardPicker {return &StaticShardPicker{index: }}func ( *StaticShardPicker) ( int) int {if == 0 || .index >= {return 0}return .index}/*───────────────────────────────Round-robin (default)────────────────────────────────*/type RoundRobinPicker struct {cnt atomic.Uint32}func ( *RoundRobinPicker) ( int) int {if == 0 {return 0}:= .cnt.Add(1)return int(-1) %}/*───────────────────────────────Random────────────────────────────────*/type RandomPicker struct{}func (RandomPicker) ( int) int {if == 0 {return 0}return rand.Intn()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |