Skip to content

Commit 584db04

Browse files
committed
Link documentation for all cluster commands
Added links to the documentation in the docstrings in redis/commands/cluster.py Part of #1712
1 parent ef4caf5 commit 584db04

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

redis/commands/cluster.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def mget_nonatomic(self, keys, *args):
4141
if keys belong to more than one slot.
4242
4343
Returns a list of values ordered identically to ``keys``
44+
45+
For more information check https://redis.io/commands/mget
4446
"""
4547

4648
from redis.client import EMPTY_RESPONSE
@@ -77,6 +79,8 @@ def mset_nonatomic(self, mapping):
7779
Splits the keys into different slots and then calls MSET
7880
for the keys of every slot. This operation will not be atomic
7981
if keys belong to more than one slot.
82+
83+
For more information check https://redis.io/commands/mset
8084
"""
8185

8286
# Partition the keys by slot
@@ -115,6 +119,8 @@ def exists(self, *keys):
115119
Returns the number of ``names`` that exist in the
116120
whole cluster. The keys are first split up into slots
117121
and then an EXISTS command is sent for every slot
122+
123+
For more information check https://redis.io/commands/exists
118124
"""
119125
return self._split_command_across_slots("EXISTS", *keys)
120126

@@ -126,6 +132,8 @@ def delete(self, *keys):
126132
127133
Non-existant keys are ignored.
128134
Returns the number of keys that were deleted.
135+
136+
For more information check https://redis.io/commands/del
129137
"""
130138
return self._split_command_across_slots("DEL", *keys)
131139

@@ -139,6 +147,8 @@ def touch(self, *keys):
139147
140148
Non-existant keys are ignored.
141149
Returns the number of keys that were touched.
150+
151+
For more information check https://redis.io/commands/touch
142152
"""
143153
return self._split_command_across_slots("TOUCH", *keys)
144154

@@ -151,6 +161,8 @@ def unlink(self, *keys):
151161
152162
Non-existant keys are ignored.
153163
Returns the number of keys that were unlinked.
164+
165+
For more information check https://redis.io/commands/unlink
154166
"""
155167
return self._split_command_across_slots("UNLINK", *keys)
156168

@@ -164,12 +176,27 @@ class ClusterManagementCommands(ManagementCommands):
164176
"""
165177

166178
def slaveof(self, *args, **kwargs):
179+
"""
180+
Make the server a replica of another instance, or promote it as master.
181+
182+
For more information check https://redis.io/commands/slaveof
183+
"""
167184
raise RedisClusterException("SLAVEOF is not supported in cluster mode")
168185

169186
def replicaof(self, *args, **kwargs):
187+
"""
188+
Make the server a replica of another instance, or promote it as master.
189+
190+
For more information check https://redis.io/commands/replicaof
191+
"""
170192
raise RedisClusterException("REPLICAOF is not supported in cluster" " mode")
171193

172194
def swapdb(self, *args, **kwargs):
195+
"""
196+
Swaps two Redis databases.
197+
198+
For more information check https://redis.io/commands/swapdb
199+
"""
173200
raise RedisClusterException("SWAPDB is not supported in cluster" " mode")
174201

175202

@@ -193,6 +220,9 @@ def stralgo(
193220
withmatchlen=False,
194221
**kwargs,
195222
):
223+
"""
224+
For more information check https://redis.io/commands/stralgo
225+
"""
196226
target_nodes = kwargs.pop("target_nodes", None)
197227
if specific_argument == "strings" and target_nodes is None:
198228
target_nodes = "default-node"
@@ -281,6 +311,8 @@ def cluster_addslots(self, target_node, *slots):
281311
282312
:target_node: 'ClusterNode'
283313
The node to execute the command on
314+
315+
For more information check https://redis.io/commands/cluster-addslots
284316
"""
285317
return self.execute_command(
286318
"CLUSTER ADDSLOTS", *slots, target_nodes=target_node
@@ -306,13 +338,17 @@ def cluster_countkeysinslot(self, slot_id):
306338
"""
307339
Return the number of local keys in the specified hash slot
308340
Send to node based on specified slot_id
341+
342+
For more information check https://redis.io/commands/cluster-countkeysinslot
309343
"""
310344
return self.execute_command("CLUSTER COUNTKEYSINSLOT", slot_id)
311345

312346
def cluster_count_failure_report(self, node_id):
313347
"""
314348
Return the number of failure reports active for a given node
315349
Sends to a random node
350+
351+
For more information check https://redis.io/commands/cluster-count-failure-reports
316352
"""
317353
return self.execute_command("CLUSTER COUNT-FAILURE-REPORTS", node_id)
318354

@@ -322,6 +358,8 @@ def cluster_delslots(self, *slots):
322358
It determines by it self what node the slot is in and sends it there
323359
324360
Returns a list of the results for each processed slot.
361+
362+
For more information check https://redis.io/commands/cluster-delslots
325363
"""
326364
return [self.execute_command("CLUSTER DELSLOTS", slot) for slot in slots]
327365

@@ -343,6 +381,8 @@ def cluster_failover(self, target_node, option=None):
343381
344382
:target_node: 'ClusterNode'
345383
The node to execute the command on
384+
385+
For more information check https://redis.io/commands/cluster-failover
346386
"""
347387
if option:
348388
if option.upper() not in ["FORCE", "TAKEOVER"]:
@@ -361,36 +401,45 @@ def cluster_info(self, target_nodes=None):
361401
Provides info about Redis Cluster node state.
362402
The command will be sent to a random node in the cluster if no target
363403
node is specified.
404+
405+
For more information check https://redis.io/commands/cluster-info
364406
"""
365407
return self.execute_command("CLUSTER INFO", target_nodes=target_nodes)
366408

367409
def cluster_keyslot(self, key):
368410
"""
369411
Returns the hash slot of the specified key
370412
Sends to random node in the cluster
413+
414+
For more information check https://redis.io/commands/cluster-keyslot
371415
"""
372416
return self.execute_command("CLUSTER KEYSLOT", key)
373417

374418
def cluster_meet(self, host, port, target_nodes=None):
375419
"""
376420
Force a node cluster to handshake with another node.
377421
Sends to specified node.
422+
423+
For more information check https://redis.io/commands/cluster-meet
378424
"""
379425
return self.execute_command(
380426
"CLUSTER MEET", host, port, target_nodes=target_nodes
381427
)
382428

383429
def cluster_nodes(self):
384430
"""
385-
Force a node cluster to handshake with another node
386-
431+
Get Cluster config for the node.
387432
Sends to random node in the cluster
433+
434+
For more information check https://redis.io/commands/cluster-nodes
388435
"""
389436
return self.execute_command("CLUSTER NODES")
390437

391438
def cluster_replicate(self, target_nodes, node_id):
392439
"""
393440
Reconfigure a node as a slave of the specified master node
441+
442+
For more information check https://redis.io/commands/cluster-replicate
394443
"""
395444
return self.execute_command(
396445
"CLUSTER REPLICATE", node_id, target_nodes=target_nodes
@@ -402,6 +451,8 @@ def cluster_reset(self, soft=True, target_nodes=None):
402451
403452
If 'soft' is True then it will send 'SOFT' argument
404453
If 'soft' is False then it will send 'HARD' argument
454+
455+
For more information check https://redis.io/commands/cluster-reset
405456
"""
406457
return self.execute_command(
407458
"CLUSTER RESET", b"SOFT" if soft else b"HARD", target_nodes=target_nodes
@@ -410,18 +461,24 @@ def cluster_reset(self, soft=True, target_nodes=None):
410461
def cluster_save_config(self, target_nodes=None):
411462
"""
412463
Forces the node to save cluster state on disk
464+
465+
For more information check https://redis.io/commands/cluster-saveconfig
413466
"""
414467
return self.execute_command("CLUSTER SAVECONFIG", target_nodes=target_nodes)
415468

416469
def cluster_get_keys_in_slot(self, slot, num_keys):
417470
"""
418471
Returns the number of keys in the specified cluster slot
472+
473+
For more information check https://redis.io/commands/cluster-getkeysinslot
419474
"""
420475
return self.execute_command("CLUSTER GETKEYSINSLOT", slot, num_keys)
421476

422477
def cluster_set_config_epoch(self, epoch, target_nodes=None):
423478
"""
424479
Set the configuration epoch in a new node
480+
481+
For more information check https://redis.io/commands/cluster-set-config-epoch
425482
"""
426483
return self.execute_command(
427484
"CLUSTER SET-CONFIG-EPOCH", epoch, target_nodes=target_nodes
@@ -433,6 +490,8 @@ def cluster_setslot(self, target_node, node_id, slot_id, state):
433490
434491
:target_node: 'ClusterNode'
435492
The node to execute the command on
493+
494+
For more information check https://redis.io/commands/cluster-setslot
436495
"""
437496
if state.upper() in ("IMPORTING", "NODE", "MIGRATING"):
438497
return self.execute_command(
@@ -447,13 +506,17 @@ def cluster_setslot_stable(self, slot_id):
447506
"""
448507
Clears migrating / importing state from the slot.
449508
It determines by it self what node the slot is in and sends it there.
509+
510+
For more information check https://redis.io/commands/cluster-setslot
450511
"""
451512
return self.execute_command("CLUSTER SETSLOT", slot_id, "STABLE")
452513

453514
def cluster_replicas(self, node_id, target_nodes=None):
454515
"""
455516
Provides a list of replica nodes replicating from the specified primary
456517
target node.
518+
519+
For more information check https://redis.io/commands/cluster-replicas
457520
"""
458521
return self.execute_command(
459522
"CLUSTER REPLICAS", node_id, target_nodes=target_nodes
@@ -462,6 +525,8 @@ def cluster_replicas(self, node_id, target_nodes=None):
462525
def cluster_slots(self, target_nodes=None):
463526
"""
464527
Get array of Cluster slot to node mappings
528+
529+
For more information check https://redis.io/commands/cluster-slots
465530
"""
466531
return self.execute_command("CLUSTER SLOTS", target_nodes=target_nodes)
467532

@@ -482,6 +547,8 @@ def readonly(self, target_nodes=None):
482547
Enables read queries.
483548
The command will be sent to the default cluster node if target_nodes is
484549
not specified.
550+
551+
For more information check https://redis.io/commands/readonly
485552
"""
486553
if target_nodes == "replicas" or target_nodes == "all":
487554
# read_from_replicas will only be enabled if the READONLY command
@@ -494,6 +561,8 @@ def readwrite(self, target_nodes=None):
494561
Disables read queries.
495562
The command will be sent to the default cluster node if target_nodes is
496563
not specified.
564+
565+
For more information check https://redis.io/commands/readwrite
497566
"""
498567
# Reset read from replicas flag
499568
self.read_from_replicas = False

0 commit comments

Comments
 (0)