mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
Execute "COMMAND" command only when readonly (#2815)
* remove command command from oss cluster * remove command command from oss cluster * remove cmdInfo from ring --------- Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
18
ring.go
18
ring.go
@ -678,21 +678,8 @@ func (c *Ring) cmdsInfo(ctx context.Context) (map[string]*CommandInfo, error) {
|
||||
return nil, firstErr
|
||||
}
|
||||
|
||||
func (c *Ring) cmdInfo(ctx context.Context, name string) *CommandInfo {
|
||||
cmdsInfo, err := c.cmdsInfoCache.Get(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
info := cmdsInfo[name]
|
||||
if info == nil {
|
||||
internal.Logger.Printf(ctx, "info for cmd=%s not found", name)
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (c *Ring) cmdShard(ctx context.Context, cmd Cmder) (*ringShard, error) {
|
||||
cmdInfo := c.cmdInfo(ctx, cmd.Name())
|
||||
pos := cmdFirstKeyPos(cmd, cmdInfo)
|
||||
pos := cmdFirstKeyPos(cmd)
|
||||
if pos == 0 {
|
||||
return c.sharding.Random()
|
||||
}
|
||||
@ -760,8 +747,7 @@ func (c *Ring) generalProcessPipeline(
|
||||
cmdsMap := make(map[string][]Cmder)
|
||||
|
||||
for _, cmd := range cmds {
|
||||
cmdInfo := c.cmdInfo(ctx, cmd.Name())
|
||||
hash := cmd.stringArg(cmdFirstKeyPos(cmd, cmdInfo))
|
||||
hash := cmd.stringArg(cmdFirstKeyPos(cmd))
|
||||
if hash != "" {
|
||||
hash = c.sharding.Hash(hash)
|
||||
}
|
||||
|
Reference in New Issue
Block a user