MCPcopy
hub / github.com/redis/go-redis / cmdShard

Method cmdShard

ring.go:777–787  ·  view source on GitHub ↗
(cmd Cmder)

Source from the content-addressed store, hash-verified

775}
776
777func (c *Ring) cmdShard(cmd Cmder) (*ringShard, error) {
778 // TODO: populate cmdsInfoCache lazily (via cmdsInfoCache.Get) so that
779 // the warm-cache branch in cmdFirstKeyPosWithInfo is reachable for Ring,
780 // mirroring how ClusterClient.cmdInfo works. For now pass nil
781 pos := cmdFirstKeyPosWithInfo(cmd, nil)
782 if pos == 0 {
783 return c.sharding.Random()
784 }
785 firstKey := cmd.stringArg(pos)
786 return c.sharding.GetByKey(firstKey)
787}
788
789func (c *Ring) process(ctx context.Context, cmd Cmder) error {
790 var lastErr error

Callers 1

processMethod · 0.95

Calls 4

cmdFirstKeyPosWithInfoFunction · 0.85
GetByKeyMethod · 0.80
stringArgMethod · 0.65
RandomMethod · 0.45

Tested by

no test coverage detected