@@ -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 see 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 see 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 see 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 see 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 see 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 see 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 see 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 see 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 see https://redis.io/commands/swapdb
199
+ """
173
200
raise RedisClusterException ("SWAPDB is not supported in cluster" " mode" )
174
201
175
202
@@ -193,6 +220,25 @@ def stralgo(
193
220
withmatchlen = False ,
194
221
** kwargs ,
195
222
):
223
+ """
224
+ Implements complex algorithms that operate on strings.
225
+ Right now the only algorithm implemented is the LCS algorithm
226
+ (longest common substring). However new algorithms could be
227
+ implemented in the future.
228
+
229
+ ``algo`` Right now must be LCS
230
+ ``value1`` and ``value2`` Can be two strings or two keys
231
+ ``specific_argument`` Specifying if the arguments to the algorithm
232
+ will be keys or strings. strings is the default.
233
+ ``len`` Returns just the len of the match.
234
+ ``idx`` Returns the match positions in each string.
235
+ ``minmatchlen`` Restrict the list of matches to the ones of a given
236
+ minimal length. Can be provided only when ``idx`` set to True.
237
+ ``withmatchlen`` Returns the matches with the len of the match.
238
+ Can be provided only when ``idx`` set to True.
239
+
240
+ For more information see https://redis.io/commands/stralgo
241
+ """
196
242
target_nodes = kwargs .pop ("target_nodes" , None )
197
243
if specific_argument == "strings" and target_nodes is None :
198
244
target_nodes = "default-node"
@@ -292,6 +338,8 @@ def cluster_addslots(self, target_node, *slots):
292
338
293
339
:target_node: 'ClusterNode'
294
340
The node to execute the command on
341
+
342
+ For more information see https://redis.io/commands/cluster-addslots
295
343
"""
296
344
return self .execute_command (
297
345
"CLUSTER ADDSLOTS" , * slots , target_nodes = target_node
@@ -307,7 +355,7 @@ def cluster_addslotsrange(self, target_node, *slots):
307
355
:target_node: 'ClusterNode'
308
356
The node to execute the command on
309
357
310
- For more information check https://redis.io/commands/cluster-addslotsrange
358
+ For more information see https://redis.io/commands/cluster-addslotsrange
311
359
"""
312
360
return self .execute_command (
313
361
"CLUSTER ADDSLOTSRANGE" , * slots , target_nodes = target_node
@@ -317,13 +365,17 @@ def cluster_countkeysinslot(self, slot_id):
317
365
"""
318
366
Return the number of local keys in the specified hash slot
319
367
Send to node based on specified slot_id
368
+
369
+ For more information see https://redis.io/commands/cluster-countkeysinslot
320
370
"""
321
371
return self .execute_command ("CLUSTER COUNTKEYSINSLOT" , slot_id )
322
372
323
373
def cluster_count_failure_report (self , node_id ):
324
374
"""
325
375
Return the number of failure reports active for a given node
326
376
Sends to a random node
377
+
378
+ For more information see https://redis.io/commands/cluster-count-failure-reports
327
379
"""
328
380
return self .execute_command ("CLUSTER COUNT-FAILURE-REPORTS" , node_id )
329
381
@@ -333,6 +385,8 @@ def cluster_delslots(self, *slots):
333
385
It determines by it self what node the slot is in and sends it there
334
386
335
387
Returns a list of the results for each processed slot.
388
+
389
+ For more information see https://redis.io/commands/cluster-delslots
336
390
"""
337
391
return [self .execute_command ("CLUSTER DELSLOTS" , slot ) for slot in slots ]
338
392
@@ -343,7 +397,7 @@ def cluster_delslotsrange(self, *slots):
343
397
from the node, while CLUSTER DELSLOTSRANGE takes a list of slot ranges to remove
344
398
from the node.
345
399
346
- For more information check https://redis.io/commands/cluster-delslotsrange
400
+ For more information see https://redis.io/commands/cluster-delslotsrange
347
401
"""
348
402
return self .execute_command ("CLUSTER DELSLOTSRANGE" , * slots )
349
403
@@ -354,6 +408,8 @@ def cluster_failover(self, target_node, option=None):
354
408
355
409
:target_node: 'ClusterNode'
356
410
The node to execute the command on
411
+
412
+ For more information see https://redis.io/commands/cluster-failover
357
413
"""
358
414
if option :
359
415
if option .upper () not in ["FORCE" , "TAKEOVER" ]:
@@ -372,36 +428,45 @@ def cluster_info(self, target_nodes=None):
372
428
Provides info about Redis Cluster node state.
373
429
The command will be sent to a random node in the cluster if no target
374
430
node is specified.
431
+
432
+ For more information see https://redis.io/commands/cluster-info
375
433
"""
376
434
return self .execute_command ("CLUSTER INFO" , target_nodes = target_nodes )
377
435
378
436
def cluster_keyslot (self , key ):
379
437
"""
380
438
Returns the hash slot of the specified key
381
439
Sends to random node in the cluster
440
+
441
+ For more information see https://redis.io/commands/cluster-keyslot
382
442
"""
383
443
return self .execute_command ("CLUSTER KEYSLOT" , key )
384
444
385
445
def cluster_meet (self , host , port , target_nodes = None ):
386
446
"""
387
447
Force a node cluster to handshake with another node.
388
448
Sends to specified node.
449
+
450
+ For more information see https://redis.io/commands/cluster-meet
389
451
"""
390
452
return self .execute_command (
391
453
"CLUSTER MEET" , host , port , target_nodes = target_nodes
392
454
)
393
455
394
456
def cluster_nodes (self ):
395
457
"""
396
- Force a node cluster to handshake with another node
397
-
458
+ Get Cluster config for the node.
398
459
Sends to random node in the cluster
460
+
461
+ For more information see https://redis.io/commands/cluster-nodes
399
462
"""
400
463
return self .execute_command ("CLUSTER NODES" )
401
464
402
465
def cluster_replicate (self , target_nodes , node_id ):
403
466
"""
404
467
Reconfigure a node as a slave of the specified master node
468
+
469
+ For more information see https://redis.io/commands/cluster-replicate
405
470
"""
406
471
return self .execute_command (
407
472
"CLUSTER REPLICATE" , node_id , target_nodes = target_nodes
@@ -413,6 +478,8 @@ def cluster_reset(self, soft=True, target_nodes=None):
413
478
414
479
If 'soft' is True then it will send 'SOFT' argument
415
480
If 'soft' is False then it will send 'HARD' argument
481
+
482
+ For more information see https://redis.io/commands/cluster-reset
416
483
"""
417
484
return self .execute_command (
418
485
"CLUSTER RESET" , b"SOFT" if soft else b"HARD" , target_nodes = target_nodes
@@ -421,18 +488,24 @@ def cluster_reset(self, soft=True, target_nodes=None):
421
488
def cluster_save_config (self , target_nodes = None ):
422
489
"""
423
490
Forces the node to save cluster state on disk
491
+
492
+ For more information see https://redis.io/commands/cluster-saveconfig
424
493
"""
425
494
return self .execute_command ("CLUSTER SAVECONFIG" , target_nodes = target_nodes )
426
495
427
496
def cluster_get_keys_in_slot (self , slot , num_keys ):
428
497
"""
429
498
Returns the number of keys in the specified cluster slot
499
+
500
+ For more information see https://redis.io/commands/cluster-getkeysinslot
430
501
"""
431
502
return self .execute_command ("CLUSTER GETKEYSINSLOT" , slot , num_keys )
432
503
433
504
def cluster_set_config_epoch (self , epoch , target_nodes = None ):
434
505
"""
435
506
Set the configuration epoch in a new node
507
+
508
+ For more information see https://redis.io/commands/cluster-set-config-epoch
436
509
"""
437
510
return self .execute_command (
438
511
"CLUSTER SET-CONFIG-EPOCH" , epoch , target_nodes = target_nodes
@@ -444,6 +517,8 @@ def cluster_setslot(self, target_node, node_id, slot_id, state):
444
517
445
518
:target_node: 'ClusterNode'
446
519
The node to execute the command on
520
+
521
+ For more information see https://redis.io/commands/cluster-setslot
447
522
"""
448
523
if state .upper () in ("IMPORTING" , "NODE" , "MIGRATING" ):
449
524
return self .execute_command (
@@ -458,13 +533,17 @@ def cluster_setslot_stable(self, slot_id):
458
533
"""
459
534
Clears migrating / importing state from the slot.
460
535
It determines by it self what node the slot is in and sends it there.
536
+
537
+ For more information see https://redis.io/commands/cluster-setslot
461
538
"""
462
539
return self .execute_command ("CLUSTER SETSLOT" , slot_id , "STABLE" )
463
540
464
541
def cluster_replicas (self , node_id , target_nodes = None ):
465
542
"""
466
543
Provides a list of replica nodes replicating from the specified primary
467
544
target node.
545
+
546
+ For more information see https://redis.io/commands/cluster-replicas
468
547
"""
469
548
return self .execute_command (
470
549
"CLUSTER REPLICAS" , node_id , target_nodes = target_nodes
@@ -473,6 +552,8 @@ def cluster_replicas(self, node_id, target_nodes=None):
473
552
def cluster_slots (self , target_nodes = None ):
474
553
"""
475
554
Get array of Cluster slot to node mappings
555
+
556
+ For more information see https://redis.io/commands/cluster-slots
476
557
"""
477
558
return self .execute_command ("CLUSTER SLOTS" , target_nodes = target_nodes )
478
559
@@ -484,7 +565,7 @@ def cluster_links(self, target_node):
484
565
485
566
This command outputs information of all such peer links as an array.
486
567
487
- For more information check https://redis.io/commands/cluster-links
568
+ For more information see https://redis.io/commands/cluster-links
488
569
"""
489
570
return self .execute_command ("CLUSTER LINKS" , target_nodes = target_node )
490
571
@@ -493,6 +574,8 @@ def readonly(self, target_nodes=None):
493
574
Enables read queries.
494
575
The command will be sent to the default cluster node if target_nodes is
495
576
not specified.
577
+
578
+ For more information see https://redis.io/commands/readonly
496
579
"""
497
580
if target_nodes == "replicas" or target_nodes == "all" :
498
581
# read_from_replicas will only be enabled if the READONLY command
@@ -505,6 +588,8 @@ def readwrite(self, target_nodes=None):
505
588
Disables read queries.
506
589
The command will be sent to the default cluster node if target_nodes is
507
590
not specified.
591
+
592
+ For more information see https://redis.io/commands/readwrite
508
593
"""
509
594
# Reset read from replicas flag
510
595
self .read_from_replicas = False
0 commit comments