...

Source file src/github.com/redis/go-redis/v9/cluster_commands.go

Documentation: github.com/redis/go-redis/v9

     1  package redis
     2  
     3  import "context"
     4  
     5  type ClusterCmdable interface {
     6  	ClusterMyShardID(ctx context.Context) *StringCmd
     7  	ClusterMyID(ctx context.Context) *StringCmd
     8  	ClusterSlots(ctx context.Context) *ClusterSlotsCmd
     9  	ClusterShards(ctx context.Context) *ClusterShardsCmd
    10  	ClusterLinks(ctx context.Context) *ClusterLinksCmd
    11  	ClusterNodes(ctx context.Context) *StringCmd
    12  	ClusterMeet(ctx context.Context, host, port string) *StatusCmd
    13  	ClusterForget(ctx context.Context, nodeID string) *StatusCmd
    14  	ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd
    15  	ClusterResetSoft(ctx context.Context) *StatusCmd
    16  	ClusterResetHard(ctx context.Context) *StatusCmd
    17  	ClusterInfo(ctx context.Context) *StringCmd
    18  	ClusterKeySlot(ctx context.Context, key string) *IntCmd
    19  	ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd
    20  	ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd
    21  	ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd
    22  	ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd
    23  	ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd
    24  	ClusterSaveConfig(ctx context.Context) *StatusCmd
    25  	ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd
    26  	ClusterFailover(ctx context.Context) *StatusCmd
    27  	ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd
    28  	ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd
    29  	ReadOnly(ctx context.Context) *StatusCmd
    30  	ReadWrite(ctx context.Context) *StatusCmd
    31  }
    32  
    33  func (c cmdable) ClusterMyShardID(ctx context.Context) *StringCmd {
    34  	cmd := NewStringCmd(ctx, "cluster", "myshardid")
    35  	_ = c(ctx, cmd)
    36  	return cmd
    37  }
    38  
    39  func (c cmdable) ClusterMyID(ctx context.Context) *StringCmd {
    40  	cmd := NewStringCmd(ctx, "cluster", "myid")
    41  	_ = c(ctx, cmd)
    42  	return cmd
    43  }
    44  
    45  func (c cmdable) ClusterSlots(ctx context.Context) *ClusterSlotsCmd {
    46  	cmd := NewClusterSlotsCmd(ctx, "cluster", "slots")
    47  	_ = c(ctx, cmd)
    48  	return cmd
    49  }
    50  
    51  func (c cmdable) ClusterShards(ctx context.Context) *ClusterShardsCmd {
    52  	cmd := NewClusterShardsCmd(ctx, "cluster", "shards")
    53  	_ = c(ctx, cmd)
    54  	return cmd
    55  }
    56  
    57  func (c cmdable) ClusterLinks(ctx context.Context) *ClusterLinksCmd {
    58  	cmd := NewClusterLinksCmd(ctx, "cluster", "links")
    59  	_ = c(ctx, cmd)
    60  	return cmd
    61  }
    62  
    63  func (c cmdable) ClusterNodes(ctx context.Context) *StringCmd {
    64  	cmd := NewStringCmd(ctx, "cluster", "nodes")
    65  	_ = c(ctx, cmd)
    66  	return cmd
    67  }
    68  
    69  func (c cmdable) ClusterMeet(ctx context.Context, host, port string) *StatusCmd {
    70  	cmd := NewStatusCmd(ctx, "cluster", "meet", host, port)
    71  	_ = c(ctx, cmd)
    72  	return cmd
    73  }
    74  
    75  func (c cmdable) ClusterForget(ctx context.Context, nodeID string) *StatusCmd {
    76  	cmd := NewStatusCmd(ctx, "cluster", "forget", nodeID)
    77  	_ = c(ctx, cmd)
    78  	return cmd
    79  }
    80  
    81  func (c cmdable) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd {
    82  	cmd := NewStatusCmd(ctx, "cluster", "replicate", nodeID)
    83  	_ = c(ctx, cmd)
    84  	return cmd
    85  }
    86  
    87  func (c cmdable) ClusterResetSoft(ctx context.Context) *StatusCmd {
    88  	cmd := NewStatusCmd(ctx, "cluster", "reset", "soft")
    89  	_ = c(ctx, cmd)
    90  	return cmd
    91  }
    92  
    93  func (c cmdable) ClusterResetHard(ctx context.Context) *StatusCmd {
    94  	cmd := NewStatusCmd(ctx, "cluster", "reset", "hard")
    95  	_ = c(ctx, cmd)
    96  	return cmd
    97  }
    98  
    99  func (c cmdable) ClusterInfo(ctx context.Context) *StringCmd {
   100  	cmd := NewStringCmd(ctx, "cluster", "info")
   101  	_ = c(ctx, cmd)
   102  	return cmd
   103  }
   104  
   105  func (c cmdable) ClusterKeySlot(ctx context.Context, key string) *IntCmd {
   106  	cmd := NewIntCmd(ctx, "cluster", "keyslot", key)
   107  	_ = c(ctx, cmd)
   108  	return cmd
   109  }
   110  
   111  func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd {
   112  	cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", slot, count)
   113  	_ = c(ctx, cmd)
   114  	return cmd
   115  }
   116  
   117  func (c cmdable) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd {
   118  	cmd := NewIntCmd(ctx, "cluster", "count-failure-reports", nodeID)
   119  	_ = c(ctx, cmd)
   120  	return cmd
   121  }
   122  
   123  func (c cmdable) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd {
   124  	cmd := NewIntCmd(ctx, "cluster", "countkeysinslot", slot)
   125  	_ = c(ctx, cmd)
   126  	return cmd
   127  }
   128  
   129  func (c cmdable) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd {
   130  	args := make([]interface{}, 2+len(slots))
   131  	args[0] = "cluster"
   132  	args[1] = "delslots"
   133  	for i, slot := range slots {
   134  		args[2+i] = slot
   135  	}
   136  	cmd := NewStatusCmd(ctx, args...)
   137  	_ = c(ctx, cmd)
   138  	return cmd
   139  }
   140  
   141  func (c cmdable) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd {
   142  	size := max - min + 1
   143  	slots := make([]int, size)
   144  	for i := 0; i < size; i++ {
   145  		slots[i] = min + i
   146  	}
   147  	return c.ClusterDelSlots(ctx, slots...)
   148  }
   149  
   150  func (c cmdable) ClusterSaveConfig(ctx context.Context) *StatusCmd {
   151  	cmd := NewStatusCmd(ctx, "cluster", "saveconfig")
   152  	_ = c(ctx, cmd)
   153  	return cmd
   154  }
   155  
   156  func (c cmdable) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd {
   157  	cmd := NewStringSliceCmd(ctx, "cluster", "slaves", nodeID)
   158  	_ = c(ctx, cmd)
   159  	return cmd
   160  }
   161  
   162  func (c cmdable) ClusterFailover(ctx context.Context) *StatusCmd {
   163  	cmd := NewStatusCmd(ctx, "cluster", "failover")
   164  	_ = c(ctx, cmd)
   165  	return cmd
   166  }
   167  
   168  func (c cmdable) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd {
   169  	args := make([]interface{}, 2+len(slots))
   170  	args[0] = "cluster"
   171  	args[1] = "addslots"
   172  	for i, num := range slots {
   173  		args[2+i] = num
   174  	}
   175  	cmd := NewStatusCmd(ctx, args...)
   176  	_ = c(ctx, cmd)
   177  	return cmd
   178  }
   179  
   180  func (c cmdable) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd {
   181  	size := max - min + 1
   182  	slots := make([]int, size)
   183  	for i := 0; i < size; i++ {
   184  		slots[i] = min + i
   185  	}
   186  	return c.ClusterAddSlots(ctx, slots...)
   187  }
   188  
   189  func (c cmdable) ReadOnly(ctx context.Context) *StatusCmd {
   190  	cmd := NewStatusCmd(ctx, "readonly")
   191  	_ = c(ctx, cmd)
   192  	return cmd
   193  }
   194  
   195  func (c cmdable) ReadWrite(ctx context.Context) *StatusCmd {
   196  	cmd := NewStatusCmd(ctx, "readwrite")
   197  	_ = c(ctx, cmd)
   198  	return cmd
   199  }
   200  

View as plain text