@@ -859,15 +859,19 @@ func (c *clusterState) slotNodes(slot int) []*clusterNode {
859859//------------------------------------------------------------------------------
860860
861861type clusterStateHolder struct {
862- load func (ctx context.Context ) (* clusterState , error )
863-
864- state atomic.Value
865- reloading uint32 // atomic
862+ load func (ctx context.Context ) (* clusterState , error )
863+ commandsCacheRefresh func ()
864+ state atomic.Value
865+ reloading uint32 // atomic
866866}
867867
868- func newClusterStateHolder (fn func (ctx context.Context ) (* clusterState , error )) * clusterStateHolder {
868+ func newClusterStateHolder (
869+ load func (ctx context.Context ) (* clusterState , error ),
870+ commandsCacheRefresh func (),
871+ ) * clusterStateHolder {
869872 return & clusterStateHolder {
870- load : fn ,
873+ load : load ,
874+ commandsCacheRefresh : commandsCacheRefresh ,
871875 }
872876}
873877
@@ -876,6 +880,7 @@ func (c *clusterStateHolder) Reload(ctx context.Context) (*clusterState, error)
876880 if err != nil {
877881 return nil , err
878882 }
883+ c .commandsCacheRefresh ()
879884 c .state .Store (state )
880885 return state , nil
881886}
@@ -940,9 +945,9 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
940945 nodes : newClusterNodes (opt ),
941946 }
942947
943- c .state = newClusterStateHolder (c .loadState )
944- // TODO: execute on handshake, should be called again on reconnect
945948 c .cmdsInfoCache = newCmdsInfoCache (c .cmdsInfo )
949+
950+ c .state = newClusterStateHolder (c .loadState , c .cmdsInfoCache .Refresh )
946951 c .cmdable = c .Process
947952 c .initHooks (hooks {
948953 dial : nil ,
0 commit comments