@@ -907,7 +907,6 @@ func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error {
907907}
908908
909909func (c * ClusterClient ) process (ctx context.Context , cmd Cmder ) error {
910- cmdInfo := c .cmdInfo (ctx , cmd .Name ())
911910 slot := c .cmdSlot (ctx , cmd )
912911 var node * clusterNode
913912 var ask bool
@@ -921,7 +920,7 @@ func (c *ClusterClient) process(ctx context.Context, cmd Cmder) error {
921920
922921 if node == nil {
923922 var err error
924- node , err = c .cmdNode (ctx , cmdInfo , slot )
923+ node , err = c .cmdNode (ctx , cmd . Name () , slot )
925924 if err != nil {
926925 return err
927926 }
@@ -1783,8 +1782,7 @@ func (c *ClusterClient) cmdSlot(ctx context.Context, cmd Cmder) int {
17831782 return args [2 ].(int )
17841783 }
17851784
1786- cmdInfo := c .cmdInfo (ctx , cmd .Name ())
1787- return cmdSlot (cmd , cmdFirstKeyPos (cmd , cmdInfo ))
1785+ return cmdSlot (cmd , cmdFirstKeyPos (cmd ))
17881786}
17891787
17901788func cmdSlot (cmd Cmder , pos int ) int {
@@ -1797,16 +1795,19 @@ func cmdSlot(cmd Cmder, pos int) int {
17971795
17981796func (c * ClusterClient ) cmdNode (
17991797 ctx context.Context ,
1800- cmdInfo * CommandInfo ,
1798+ cmdName string ,
18011799 slot int ,
18021800) (* clusterNode , error ) {
18031801 state , err := c .state .Get (ctx )
18041802 if err != nil {
18051803 return nil , err
18061804 }
18071805
1808- if c .opt .ReadOnly && cmdInfo != nil && cmdInfo .ReadOnly {
1809- return c .slotReadOnlyNode (state , slot )
1806+ if c .opt .ReadOnly {
1807+ cmdInfo := c .cmdInfo (ctx , cmdName )
1808+ if cmdInfo != nil && cmdInfo .ReadOnly {
1809+ return c .slotReadOnlyNode (state , slot )
1810+ }
18101811 }
18111812 return state .slotMasterNode (slot )
18121813}
0 commit comments