@@ -41,6 +41,8 @@ def mget_nonatomic(self, keys, *args):
41
41
if keys belong to more than one slot.
42
42
43
43
Returns a list of values ordered identically to ``keys``
44
+
45
+ For more information check https://redis.io/commands/mget
44
46
"""
45
47
46
48
from redis .client import EMPTY_RESPONSE
@@ -77,6 +79,8 @@ def mset_nonatomic(self, mapping):
77
79
Splits the keys into different slots and then calls MSET
78
80
for the keys of every slot. This operation will not be atomic
79
81
if keys belong to more than one slot.
82
+
83
+ For more information check https://redis.io/commands/mset
80
84
"""
81
85
82
86
# Partition the keys by slot
@@ -115,6 +119,8 @@ def exists(self, *keys):
115
119
Returns the number of ``names`` that exist in the
116
120
whole cluster. The keys are first split up into slots
117
121
and then an EXISTS command is sent for every slot
122
+
123
+ For more information check https://redis.io/commands/exists
118
124
"""
119
125
return self ._split_command_across_slots ("EXISTS" , * keys )
120
126
@@ -126,6 +132,8 @@ def delete(self, *keys):
126
132
127
133
Non-existant keys are ignored.
128
134
Returns the number of keys that were deleted.
135
+
136
+ For more information check https://redis.io/commands/del
129
137
"""
130
138
return self ._split_command_across_slots ("DEL" , * keys )
131
139
@@ -139,6 +147,8 @@ def touch(self, *keys):
139
147
140
148
Non-existant keys are ignored.
141
149
Returns the number of keys that were touched.
150
+
151
+ For more information check https://redis.io/commands/touch
142
152
"""
143
153
return self ._split_command_across_slots ("TOUCH" , * keys )
144
154
@@ -151,6 +161,8 @@ def unlink(self, *keys):
151
161
152
162
Non-existant keys are ignored.
153
163
Returns the number of keys that were unlinked.
164
+
165
+ For more information check https://redis.io/commands/unlink
154
166
"""
155
167
return self ._split_command_across_slots ("UNLINK" , * keys )
156
168
@@ -164,12 +176,27 @@ class ClusterManagementCommands(ManagementCommands):
164
176
"""
165
177
166
178
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
+ """
167
184
raise RedisClusterException ("SLAVEOF is not supported in cluster mode" )
168
185
169
186
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
+ """
170
192
raise RedisClusterException ("REPLICAOF is not supported in cluster" " mode" )
171
193
172
194
def swapdb (self , * args , ** kwargs ):
195
+ """
196
+ Swaps two Redis databases.
197
+
198
+ For more information check https://redis.io/commands/swapdb
199
+ """
173
200
raise RedisClusterException ("SWAPDB is not supported in cluster" " mode" )
174
201
175
202
@@ -193,6 +220,9 @@ def stralgo(
193
220
withmatchlen = False ,
194
221
** kwargs ,
195
222
):
223
+ """
224
+ For more information check https://redis.io/commands/stralgo
225
+ """
196
226
target_nodes = kwargs .pop ("target_nodes" , None )
197
227
if specific_argument == "strings" and target_nodes is None :
198
228
target_nodes = "default-node"
@@ -281,6 +311,8 @@ def cluster_addslots(self, target_node, *slots):
281
311
282
312
:target_node: 'ClusterNode'
283
313
The node to execute the command on
314
+
315
+ For more information check https://redis.io/commands/cluster-addslots
284
316
"""
285
317
return self .execute_command (
286
318
"CLUSTER ADDSLOTS" , * slots , target_nodes = target_node
@@ -306,13 +338,17 @@ def cluster_countkeysinslot(self, slot_id):
306
338
"""
307
339
Return the number of local keys in the specified hash slot
308
340
Send to node based on specified slot_id
341
+
342
+ For more information check https://redis.io/commands/cluster-countkeysinslot
309
343
"""
310
344
return self .execute_command ("CLUSTER COUNTKEYSINSLOT" , slot_id )
311
345
312
346
def cluster_count_failure_report (self , node_id ):
313
347
"""
314
348
Return the number of failure reports active for a given node
315
349
Sends to a random node
350
+
351
+ For more information check https://redis.io/commands/cluster-count-failure-reports
316
352
"""
317
353
return self .execute_command ("CLUSTER COUNT-FAILURE-REPORTS" , node_id )
318
354
@@ -322,6 +358,8 @@ def cluster_delslots(self, *slots):
322
358
It determines by it self what node the slot is in and sends it there
323
359
324
360
Returns a list of the results for each processed slot.
361
+
362
+ For more information check https://redis.io/commands/cluster-delslots
325
363
"""
326
364
return [self .execute_command ("CLUSTER DELSLOTS" , slot ) for slot in slots ]
327
365
@@ -343,6 +381,8 @@ def cluster_failover(self, target_node, option=None):
343
381
344
382
:target_node: 'ClusterNode'
345
383
The node to execute the command on
384
+
385
+ For more information check https://redis.io/commands/cluster-failover
346
386
"""
347
387
if option :
348
388
if option .upper () not in ["FORCE" , "TAKEOVER" ]:
@@ -361,36 +401,45 @@ def cluster_info(self, target_nodes=None):
361
401
Provides info about Redis Cluster node state.
362
402
The command will be sent to a random node in the cluster if no target
363
403
node is specified.
404
+
405
+ For more information check https://redis.io/commands/cluster-info
364
406
"""
365
407
return self .execute_command ("CLUSTER INFO" , target_nodes = target_nodes )
366
408
367
409
def cluster_keyslot (self , key ):
368
410
"""
369
411
Returns the hash slot of the specified key
370
412
Sends to random node in the cluster
413
+
414
+ For more information check https://redis.io/commands/cluster-keyslot
371
415
"""
372
416
return self .execute_command ("CLUSTER KEYSLOT" , key )
373
417
374
418
def cluster_meet (self , host , port , target_nodes = None ):
375
419
"""
376
420
Force a node cluster to handshake with another node.
377
421
Sends to specified node.
422
+
423
+ For more information check https://redis.io/commands/cluster-meet
378
424
"""
379
425
return self .execute_command (
380
426
"CLUSTER MEET" , host , port , target_nodes = target_nodes
381
427
)
382
428
383
429
def cluster_nodes (self ):
384
430
"""
385
- Force a node cluster to handshake with another node
386
-
431
+ Get Cluster config for the node.
387
432
Sends to random node in the cluster
433
+
434
+ For more information check https://redis.io/commands/cluster-nodes
388
435
"""
389
436
return self .execute_command ("CLUSTER NODES" )
390
437
391
438
def cluster_replicate (self , target_nodes , node_id ):
392
439
"""
393
440
Reconfigure a node as a slave of the specified master node
441
+
442
+ For more information check https://redis.io/commands/cluster-replicate
394
443
"""
395
444
return self .execute_command (
396
445
"CLUSTER REPLICATE" , node_id , target_nodes = target_nodes
@@ -402,6 +451,8 @@ def cluster_reset(self, soft=True, target_nodes=None):
402
451
403
452
If 'soft' is True then it will send 'SOFT' argument
404
453
If 'soft' is False then it will send 'HARD' argument
454
+
455
+ For more information check https://redis.io/commands/cluster-reset
405
456
"""
406
457
return self .execute_command (
407
458
"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):
410
461
def cluster_save_config (self , target_nodes = None ):
411
462
"""
412
463
Forces the node to save cluster state on disk
464
+
465
+ For more information check https://redis.io/commands/cluster-saveconfig
413
466
"""
414
467
return self .execute_command ("CLUSTER SAVECONFIG" , target_nodes = target_nodes )
415
468
416
469
def cluster_get_keys_in_slot (self , slot , num_keys ):
417
470
"""
418
471
Returns the number of keys in the specified cluster slot
472
+
473
+ For more information check https://redis.io/commands/cluster-getkeysinslot
419
474
"""
420
475
return self .execute_command ("CLUSTER GETKEYSINSLOT" , slot , num_keys )
421
476
422
477
def cluster_set_config_epoch (self , epoch , target_nodes = None ):
423
478
"""
424
479
Set the configuration epoch in a new node
480
+
481
+ For more information check https://redis.io/commands/cluster-set-config-epoch
425
482
"""
426
483
return self .execute_command (
427
484
"CLUSTER SET-CONFIG-EPOCH" , epoch , target_nodes = target_nodes
@@ -433,6 +490,8 @@ def cluster_setslot(self, target_node, node_id, slot_id, state):
433
490
434
491
:target_node: 'ClusterNode'
435
492
The node to execute the command on
493
+
494
+ For more information check https://redis.io/commands/cluster-setslot
436
495
"""
437
496
if state .upper () in ("IMPORTING" , "NODE" , "MIGRATING" ):
438
497
return self .execute_command (
@@ -447,13 +506,17 @@ def cluster_setslot_stable(self, slot_id):
447
506
"""
448
507
Clears migrating / importing state from the slot.
449
508
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
450
511
"""
451
512
return self .execute_command ("CLUSTER SETSLOT" , slot_id , "STABLE" )
452
513
453
514
def cluster_replicas (self , node_id , target_nodes = None ):
454
515
"""
455
516
Provides a list of replica nodes replicating from the specified primary
456
517
target node.
518
+
519
+ For more information check https://redis.io/commands/cluster-replicas
457
520
"""
458
521
return self .execute_command (
459
522
"CLUSTER REPLICAS" , node_id , target_nodes = target_nodes
@@ -462,6 +525,8 @@ def cluster_replicas(self, node_id, target_nodes=None):
462
525
def cluster_slots (self , target_nodes = None ):
463
526
"""
464
527
Get array of Cluster slot to node mappings
528
+
529
+ For more information check https://redis.io/commands/cluster-slots
465
530
"""
466
531
return self .execute_command ("CLUSTER SLOTS" , target_nodes = target_nodes )
467
532
@@ -482,6 +547,8 @@ def readonly(self, target_nodes=None):
482
547
Enables read queries.
483
548
The command will be sent to the default cluster node if target_nodes is
484
549
not specified.
550
+
551
+ For more information check https://redis.io/commands/readonly
485
552
"""
486
553
if target_nodes == "replicas" or target_nodes == "all" :
487
554
# read_from_replicas will only be enabled if the READONLY command
@@ -494,6 +561,8 @@ def readwrite(self, target_nodes=None):
494
561
Disables read queries.
495
562
The command will be sent to the default cluster node if target_nodes is
496
563
not specified.
564
+
565
+ For more information check https://redis.io/commands/readwrite
497
566
"""
498
567
# Reset read from replicas flag
499
568
self .read_from_replicas = False
0 commit comments