
    +hJ{                        d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZmZmZ ddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ dd	l,m-Z- dd
l.m/Z/ erd dl0m1Z1  e2g d      Z3 G d de      Z4 G d de4      Z5 G d de'      Z6 G d de6e!      Z7 G d de$      Z8 G d de8e      Z9 G d de4e6ee)e8e+e%e&e(e/      Z: G d de5e7ee9e#ee e"
      Z;y)    N)TYPE_CHECKINGAnyAsyncIteratorDictIterableIteratorListMappingNoReturnOptionalUnion)Literal)key_slot)RedisClusterException
RedisError)AnyKeyTClusterCommandsProtocol
EncodableTKeysTKeyTPatternT   )ACLCommandsAsyncACLCommandsAsyncDataAccessCommandsAsyncFunctionCommandsAsyncGearsCommandsAsyncManagementCommandsAsyncModuleCommandsAsyncScriptCommandsDataAccessCommandsFunctionCommandsGearsCommandsManagementCommandsModuleCommandsPubSubCommands	ResponseTScriptCommands)list_or_args)RedisModuleCommands)TargetNodesT))BITCOUNTBITPOSEVAL_RO
EVALSHA_ROEXISTSGEODISTGEOHASHGEOPOS	GEORADIUSGEORADIUSBYMEMBERGETGETBITGETRANGEHEXISTSHGETHGETALLHKEYSHLENHMGETHSTRLENHVALSKEYSLINDEXLLENLRANGEMGETPTTL	RANDOMKEYSCARDSDIFFSINTER	SISMEMBERSMEMBERSSRANDMEMBERSTRLENSUNIONTTLZCARDZCOUNTZRANGEZSCOREc            	       X   e Zd ZdZdee   deeee   f   fdZ	de
eef   deeee   f   fdZdede
eee   f   dee   fd	Zdee   de
eee   f   d
ee   dee   fdZdededeee      fdZde
eef   dee   fdZdededefdZdedefdZdedefdZdedefdZdedefdZy)ClusterMultiKeyCommandsC
    A class containing commands that handle more than one key
    keysreturnc                     i }|D ]G  }t        | j                  j                  |            }|j                  |g       j	                  |       I |S )z@Split keys into a dictionary that maps a slot to a list of keys.)r   encoderencode
setdefaultappend)selfrX   slots_to_keyskeyslots        I/var/www/html/venv/lib/python3.12/site-packages/redis/commands/cluster.py_partition_keys_by_slotz/ClusterMultiKeyCommands._partition_keys_by_slotj   sT      	;CDLL//45D$$T2.55c:	;     mappingc                     i }|j                         D ]J  }t        | j                  j                  |d               }|j	                  |g       j                  |       L |S )zBSplit pairs into a dictionary that maps a slot to a list of pairs.r   )itemsr   r[   r\   r]   extend)r_   rf   slots_to_pairspairrb   s        rc   _partition_pairs_by_slotz0ClusterMultiKeyCommands._partition_pairs_by_slott   s^    
 MMO 	=DDLL//Q89D%%dB/66t<	= re   commandslots_to_argsc                    | j                   xr |t        v }| j                         }|j                         D cg c]6  \  }} |j                  |g|d| j
                  j                  ||      gi8 c}} |j                         S c c}}w Ntarget_nodes)read_from_replicasREAD_COMMANDSpipelinerh   execute_commandnodes_managerget_node_from_slotexecuter_   rm   rn   rr   piperb   	slot_argss          rc   _execute_pipeline_by_slotz1ClusterMultiKeyCommands._execute_pipeline_by_slot   s     "44QM9Q}} $1#6#6#8		
  i !D   &&99$@RS		
 ||~		
s   ;B		responsesc           
          t        |j                         |      D ci c]  \  }}t        ||      D ]  \  }}||
  }}}}}|D 	cg c]  }	||	   	 c}	S c c}}}}w c c}	w N)zipvalues)
r_   rX   rn   r}   slot_valuesresponsekvresultsra   s
             rc   _reorder_keys_by_commandz0ClusterMultiKeyCommands._reorder_keys_by_command   s     *-]-A-A-CY)O
 
%XK2
 1 qD

 

 )----

 .s   !A

A!argsc                     t        ||      }| j                  |      }| j                  d|      }| j                  |||      S )A  
        Splits the keys into different slots and then calls MGET
        for the keys of every slot. This operation will not be atomic
        if keys belong to more than one slot.

        Returns a list of values ordered identically to ``keys``

        For more information see https://redis.io/commands/mget
        rE   r)   rd   r|   r   r_   rX   r   r`   ress        rc   mget_nonatomicz&ClusterMultiKeyCommands.mget_nonatomic   sM     D$' 44T: ,,V]C ,,T=#FFre   c                 H    | j                  |      }| j                  d|      S )  
        Sets key/values based on a mapping. Mapping is a dictionary of
        key/value pairs. Both keys and values should be strings or types that
        can be cast to a string via str().

        Splits the keys into different slots and then calls MSET
        for the keys of every slot. This operation will not be atomic
        if keys belong to more than one slot.

        For more information see https://redis.io/commands/mset
        MSETrl   r|   r_   rf   rj   s      rc   mset_nonatomicz&ClusterMultiKeyCommands.mset_nonatomic   s)     66w? --fnEEre   c                 Z    | j                  |      }t        | j                  ||            S )v
        Runs the given command once for the keys
        of each slot. Returns the sum of the return values.
        rd   sumr|   r_   rm   rX   r`   s       rc   _split_command_across_slotsz3ClusterMultiKeyCommands._split_command_across_slots   s.     44T: 411'=IJJre   c                 (     | j                   dg| S )z
        Returns the number of ``names`` that exist in the
        whole cluster. The keys are first split up into slots
        and then an EXISTS command is sent for every slot

        For more information see https://redis.io/commands/exists
        r0   r   r_   rX   s     rc   existszClusterMultiKeyCommands.exists   s     0t//@4@@re   c                 (     | j                   dg| S )a<  
        Deletes the given keys in the cluster.
        The keys are first split up into slots
        and then an DEL command is sent for every slot

        Non-existant keys are ignored.
        Returns the number of keys that were deleted.

        For more information see https://redis.io/commands/del
        DELr   r   s     rc   deletezClusterMultiKeyCommands.delete   s     0t//===re   c                 (     | j                   dg| S )aa  
        Updates the last access time of given keys across the
        cluster.

        The keys are first split up into slots
        and then an TOUCH command is sent for every slot

        Non-existant keys are ignored.
        Returns the number of keys that were touched.

        For more information see https://redis.io/commands/touch
        TOUCHr   r   s     rc   touchzClusterMultiKeyCommands.touch   s     0t//?$??re   c                 (     | j                   dg| S )aM  
        Remove the specified keys in a different thread.

        The keys are first split up into slots
        and then an TOUCH command is sent for every slot

        Non-existant keys are ignored.
        Returns the number of keys that were unlinked.

        For more information see https://redis.io/commands/unlink
        UNLINKr   r   s     rc   unlinkzClusterMultiKeyCommands.unlink   s     0t//@4@@re   N)__name__
__module____qualname____doc__r   r   r   intr	   rd   r
   r   r   rl   strr   r|   r   r   r   r   boolr   r   r'   r   r   r   r    re   rc   rV   rV   e   s   HTN tCdO?T 
w
23
	c4
##	$
+238L3L+M	c".tn. sHZ$889. C=	.
 
c.G5 G G$x}:M G.Fggz.A&B FtDz F&
K3 
Kt 
K 
KAD AY A>D >Y >@4 @I @AD AY Are   rV   c                       e Zd ZdZdededeee      fdZ	de
eef   dee   fdZdededefd	Zded
e
eee   f   dee   fdZy)AsyncClusterMultiKeyCommandsrW   rX   r   rY   c                    K   t        ||      }| j                  |      }| j                  d|       d{   }| j                  |||      S 7 w)r   rE   Nr   r   s        rc   r   z+AsyncClusterMultiKeyCommands.mget_nonatomic  sZ      D$' 44T: 226=II ,,T=#FF Js   3AAArf   c                 d   K   | j                  |      }| j                  d|       d{   S 7 w)r   r   Nr   r   s      rc   r   z+AsyncClusterMultiKeyCommands.mset_nonatomic%  s3      66w? 33FNKKKKs   '0.0rm   c                 v   K   | j                  |      }t        | j                  ||       d{         S 7 w)r   Nr   r   s       rc   r   z8AsyncClusterMultiKeyCommands._split_command_across_slots8  s8      44T: 77OOPPOs   ,97	9rn   c                   K   | j                   r| j                          d {    | j                  xr |t        v }| j	                         }|j                         D cg c]6  \  }} |j                  |g|d| j                  j                  ||      gi8 c}} |j                          d {   S 7 c c}}w 7 wrp   )
_initialize
initializerr   rs   rt   rh   ru   rv   rw   rx   ry   s          rc   r|   z6AsyncClusterMultiKeyCommands._execute_pipeline_by_slotD  s      //###!44QM9Q}} $1#6#6#8		
  i !D   &&99$@RS		
 \\^## $		
 $s-    CB7=C ;B9C2B?3C9CN)r   r   r   r   r   r   r	   r   r   r   r
   r   r   r   r   r   r   r   r   r|   r   re   rc   r   r   	  s    G Gt GXc]@S G.LGGZ4G,H LTRVZ L&
Q 
QT 
Qc 
Q$$+238L3L+M$	c$re   r   c            
          e Zd ZdZdefdZdefdZdefdZdddefdZ	ddd	e
defd
Zddd	e
defdZdedefdZdedefdZd	e
dee   fdZd	e
defdZ	 d3dddee   defdZd3ded   defdZdedefdZ	 d3dededed   defdZdefdZdddedefdZ	 d4deded   defdZ	 d3ded   defd Zd!ed"edefd#Z	 d3d$eded   defd%Zdddeded&edef
d'Z dedefd(Z!	 d3deded   defd)Z"d3ded   defd*Z#d3d+Z$d3d,Z%dddefd-Z&d3ded   ddfd.Z'd3ded   ddfd/Z(d3ded   defd0Z)d3ded   defd1Z*defd2Z+y)5ClusterManagementCommands
    A class for Redis Cluster management commands

    The class inherits from Redis's core ManagementCommands class and do the
    required adjustments to work with cluster mode
    rY   c                     t        d      )z
        Make the server a replica of another instance, or promote it as master.

        For more information see https://redis.io/commands/slaveof
        z(SLAVEOF is not supported in cluster moder   r_   r   kwargss      rc   slaveofz!ClusterManagementCommands.slaveof`  s     $$NOOre   c                     t        d      )z
        Make the server a replica of another instance, or promote it as master.

        For more information see https://redis.io/commands/replicaof
        z*REPLICAOF is not supported in cluster moder   r   s      rc   	replicaofz#ClusterManagementCommands.replicaofh  s     $$PQQre   c                     t        d      )zo
        Swaps two Redis databases.

        For more information see https://redis.io/commands/swapdb
        z'SWAPDB is not supported in cluster moder   r   s      rc   swapdbz ClusterManagementCommands.swapdbp  s     $$MNNre   target_noder+   c                 (    | j                  d|      S )z
        Returns the node's id.

        :target_node: 'ClusterNode'
            The node to execute the command on

        For more information check https://redis.io/commands/cluster-myid/
        zCLUSTER MYIDrq   ru   r_   r   s     rc   cluster_myidz&ClusterManagementCommands.cluster_myidx  s     ##N#MMre   slotsc                 .     | j                   dg|d|iS )z
        Assign new hash slots to receiving node. Sends to specified node.

        :target_node: 'ClusterNode'
            The node to execute the command on

        For more information see https://redis.io/commands/cluster-addslots
        zCLUSTER ADDSLOTSrq   r   r_   r   r   s      rc   cluster_addslotsz*ClusterManagementCommands.cluster_addslots  s,     $t##
!&
5@
 	
re   c                 .     | j                   dg|d|iS )a  
        Similar to the CLUSTER ADDSLOTS command.
        The difference between the two commands is that ADDSLOTS takes a list of slots
        to assign to the node, while ADDSLOTSRANGE takes a list of slot ranges
        (specified by start and end slots) to assign to the node.

        :target_node: 'ClusterNode'
            The node to execute the command on

        For more information see https://redis.io/commands/cluster-addslotsrange
        zCLUSTER ADDSLOTSRANGErq   r   r   s      rc   cluster_addslotsrangez/ClusterManagementCommands.cluster_addslotsrange  s,     $t###
&+
:E
 	
re   slot_idc                 &    | j                  d|      S )z
        Return the number of local keys in the specified hash slot
        Send to node based on specified slot_id

        For more information see https://redis.io/commands/cluster-countkeysinslot
        zCLUSTER COUNTKEYSINSLOTr   r_   r   s     rc   cluster_countkeysinslotz1ClusterManagementCommands.cluster_countkeysinslot  s     ##$=wGGre   node_idc                 &    | j                  d|      S )z
        Return the number of failure reports active for a given node
        Sends to a random node

        For more information see https://redis.io/commands/cluster-count-failure-reports
        zCLUSTER COUNT-FAILURE-REPORTSr   )r_   r   s     rc   cluster_count_failure_reportz6ClusterManagementCommands.cluster_count_failure_report  s     ##$CWMMre   c                 L    |D cg c]  }| j                  d|       c}S c c}w )  
        Set hash slots as unbound in the cluster.
        It determines by it self what node the slot is in and sends it there

        Returns a list of the results for each processed slot.

        For more information see https://redis.io/commands/cluster-delslots
        CLUSTER DELSLOTSr   )r_   r   rb   s      rc   cluster_delslotsz*ClusterManagementCommands.cluster_delslots  s(     LQQ4$$%7>QQQs   !c                 (     | j                   dg| S )aQ  
        Similar to the CLUSTER DELSLOTS command.
        The difference is that CLUSTER DELSLOTS takes a list of hash slots to remove
        from the node, while CLUSTER DELSLOTSRANGE takes a list of slot ranges to remove
        from the node.

        For more information see https://redis.io/commands/cluster-delslotsrange
        zCLUSTER DELSLOTSRANGEr   r_   r   s     rc   cluster_delslotsrangez/ClusterManagementCommands.cluster_delslotsrange  s     $t##$;DeDDre   Noptionc                     |r4|j                         dvrt        d|       | j                  d||      S | j                  d|      S )a  
        Forces a slave to perform a manual failover of its master
        Sends to specified node

        :target_node: 'ClusterNode'
            The node to execute the command on

        For more information see https://redis.io/commands/cluster-failover
        )FORCETAKEOVERz-Invalid option for CLUSTER FAILOVER command: zCLUSTER FAILOVERr   )upperr   ru   )r_   r   r   s      rc   cluster_failoverz*ClusterManagementCommands.cluster_failover  sg     ||~%:: CF8L  ++&[ ,   ''(:'UUre   rq   c                 (    | j                  d|      S )z
        Provides info about Redis Cluster node state.
        The command will be sent to a random node in the cluster if no target
        node is specified.

        For more information see https://redis.io/commands/cluster-info
        zCLUSTER INFOr   r   r_   rq   s     rc   cluster_infoz&ClusterManagementCommands.cluster_info  s     ##N#NNre   ra   c                 &    | j                  d|      S )z
        Returns the hash slot of the specified key
        Sends to random node in the cluster

        For more information see https://redis.io/commands/cluster-keyslot
        zCLUSTER KEYSLOTr   )r_   ra   s     rc   cluster_keyslotz)ClusterManagementCommands.cluster_keyslot  s     ##$5s;;re   hostportc                 ,    | j                  d|||      S )z
        Force a node cluster to handshake with another node.
        Sends to specified node.

        For more information see https://redis.io/commands/cluster-meet
        zCLUSTER MEETr   r   )r_   r   r   rq   s       rc   cluster_meetz&ClusterManagementCommands.cluster_meet  s%     ##D$\ $ 
 	
re   c                 $    | j                  d      S )z
        Get Cluster config for the node.
        Sends to random node in the cluster

        For more information see https://redis.io/commands/cluster-nodes
        zCLUSTER NODESr   )r_   s    rc   cluster_nodesz'ClusterManagementCommands.cluster_nodes  s     ##O44re   c                 *    | j                  d||      S )z
        Reconfigure a node as a slave of the specified master node

        For more information see https://redis.io/commands/cluster-replicate
        zCLUSTER REPLICATEr   r   )r_   rq   r   s      rc   cluster_replicatez+ClusterManagementCommands.cluster_replicate  s#     ##| $ 
 	
re   softc                 >    | j                  d|rd|      S d|      S )z
        Reset a Redis Cluster node

        If 'soft' is True then it will send 'SOFT' argument
        If 'soft' is False then it will send 'HARD' argument

        For more information see https://redis.io/commands/cluster-reset
        zCLUSTER RESETs   SOFTs   HARDr   r   )r_   r   rq   s      rc   cluster_resetz'ClusterManagementCommands.cluster_reset  s9     ##W $ 
 	
29 $ 
 	
re   c                 (    | j                  d|      S )z
        Forces the node to save cluster state on disk

        For more information see https://redis.io/commands/cluster-saveconfig
        zCLUSTER SAVECONFIGr   r   r   s     rc   cluster_save_configz-ClusterManagementCommands.cluster_save_config(  s     ##$8|#TTre   rb   num_keysc                 (    | j                  d||      S )z
        Returns the number of keys in the specified cluster slot

        For more information see https://redis.io/commands/cluster-getkeysinslot
        zCLUSTER GETKEYSINSLOTr   )r_   rb   r   s      rc   cluster_get_keys_in_slotz2ClusterManagementCommands.cluster_get_keys_in_slot2  s     ##$;T8LLre   epochc                 *    | j                  d||      S )z
        Set the configuration epoch in a new node

        For more information see https://redis.io/commands/cluster-set-config-epoch
        zCLUSTER SET-CONFIG-EPOCHr   r   )r_   r   rq   s      rc   cluster_set_config_epochz2ClusterManagementCommands.cluster_set_config_epoch:  s#     ##&L $ 
 	
re   statec                     |j                         dv r| j                  d||||      S |j                         dk(  rt        d      t        d|       )z
        Bind an hash slot to a specific node

        :target_node: 'ClusterNode'
            The node to execute the command on

        For more information see https://redis.io/commands/cluster-setslot
        )	IMPORTINGNODE	MIGRATINGCLUSTER SETSLOTr   STABLEz4For "stable" state please use cluster_setslot_stablezInvalid slot state: )r   ru   r   )r_   r   r   r   r   s        rc   cluster_setslotz)ClusterManagementCommands.cluster_setslotF  se     ;;=>>''!7E7 (   [[]h&VWW3E7;<<re   c                 (    | j                  d|d      S )z
        Clears migrating / importing state from the slot.
        It determines by it self what node the slot is in and sends it there.

        For more information see https://redis.io/commands/cluster-setslot
        r  r  r   r   s     rc   cluster_setslot_stablez0ClusterManagementCommands.cluster_setslot_stableZ  s     ##$5wIIre   c                 *    | j                  d||      S )z
        Provides a list of replica nodes replicating from the specified primary
        target node.

        For more information see https://redis.io/commands/cluster-replicas
        zCLUSTER REPLICASr   r   )r_   r   rq   s      rc   cluster_replicasz*ClusterManagementCommands.cluster_replicasc  s#     ##l $ 
 	
re   c                 (    | j                  d|      S )z
        Get array of Cluster slot to node mappings

        For more information see https://redis.io/commands/cluster-slots
        zCLUSTER SLOTSr   r   r   s     rc   cluster_slotsz'ClusterManagementCommands.cluster_slotsp  s     ##O,#OOre   c                 (    | j                  d|      S )z
        Returns details about the shards of the cluster.

        For more information see https://redis.io/commands/cluster-shards
        zCLUSTER SHARDSr   r   r   s     rc   cluster_shardsz(ClusterManagementCommands.cluster_shardsx  s     ##$4<#PPre   c                 (    | j                  d|      S )z
        Returns the shard ID of the node.

        For more information see https://redis.io/commands/cluster-myshardid/
        zCLUSTER MYSHARDIDr   r   r   s     rc   cluster_myshardidz+ClusterManagementCommands.cluster_myshardid  s     ##$7l#SSre   c                 (    | j                  d|      S )a  
        Each node in a Redis Cluster maintains a pair of long-lived TCP link with each
        peer in the cluster: One for sending outbound messages towards the peer and one
        for receiving inbound messages from the peer.

        This command outputs information of all such peer links as an array.

        For more information see https://redis.io/commands/cluster-links
        zCLUSTER LINKSr   r   r   s     rc   cluster_linksz'ClusterManagementCommands.cluster_links  s     ##O+#NNre   c                     t        d      )NzBCLUSTER FLUSHSLOTS is intentionally not implemented in the client.NotImplementedErrorr   s     rc   cluster_flushslotsz,ClusterManagementCommands.cluster_flushslots  s    !P
 	
re   c                     t        d      )NzACLUSTER BUMPEPOCH is intentionally not implemented in the client.r  r   s     rc   cluster_bumpepochz+ClusterManagementCommands.cluster_bumpepoch  s    !O
 	
re   c                 J    |dk(  s|dk(  rd| _         | j                  d|      S )z
        Enables read queries.
        The command will be sent to the default cluster node if target_nodes is
        not specified.

        For more information see https://redis.io/commands/readonly
        replicasallTREADONLYr   rr   ru   r   s     rc   readonlyz"ClusterManagementCommands.readonly  s3     :%)> '+D###J\#JJre   c                 6    d| _         | j                  d|      S )z
        Disables read queries.
        The command will be sent to the default cluster node if target_nodes is
        not specified.

        For more information see https://redis.io/commands/readwrite
        F	READWRITEr   r  r   s     rc   	readwritez#ClusterManagementCommands.readwrite  s"     #(##Kl#KKre   c                 &     | j                   di |S )zl
        On an OSS cluster, before executing any gears function, you must call this command. # noqa
        )zREDISGEARS_2.REFRESHCLUSTERr   )r_   r   s     rc   gears_refresh_clusterz/ClusterManagementCommands.gears_refresh_cluster  s     $t##LVLLre   r   )TN),r   r   r   r   r   r   r   r   r'   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r	  r  r  r  r  r  r  r  r   r   re   rc   r   r   X  sB   P( PRH RO O	N 	N9 	N
)
3=
	

)
3=
	
$Hs Hy HNC NI N	Rz 	Rd4j 	R	EJ 	E9 	E DHV)V3;C=V	V0O.)A OY O<3 <9 < NR

"
2:>2J
	
5y 5

*

58

	

 KO

/7/G
	
  8<U$^4U	UMS MC MI M DH



(0(@

	

=)=47=BE=NQ=	=(Jc Ji J FJ

*2>*B
	
P(>*B Pi PQT
O 
OI 
O
x/G 
SW 


h~.F 
RV 

KXn%= K K
Lh~&> 
L) 
LM Mre   r   c                   &    e Zd ZdZdedee   fdZy)AsyncClusterManagementCommandsr   r   rY   c                 V    K   t        j                   fd|D          d{   S 7 w)r   c              3   h   K   | ])  }t        j                  j                  d |             + yw)r   N)asynciocreate_taskru   ).0rb   r_   s     rc   	<genexpr>zBAsyncClusterManagementCommands.cluster_delslots.<locals>.<genexpr>  s2       ##D$8$89KT$RSs   /2N)r%  gatherr   s   ` rc   r   z/AsyncClusterManagementCommands.cluster_delslots  s1      ^^!
 
 	
 
s   )')N)r   r   r   r   r   r	   r   r   r   re   rc   r"  r"    s    
Z 
DJ 
re   r"  c                        e Zd ZdZ	 	 	 	 	 dded   dededeed   ed   f   d	ed
edee	   dede
f fdZ	 	 	 ddee   dee	   dee   defdZ xZS )ClusterDataAccessCommands
    A class for Redis Cluster Data Access Commands

    The class inherits from Redis's core DataAccessCommand class and do the
    required adjustments to work with cluster mode
    stringsalgoLCSvalue1value2specific_argumentrX   lenidxminmatchlenwithmatchlenrY   c	           
          |	j                  dd      }
|dk(  r|
d}
|	j                  d|
i       t        |   ||||||||fi |	S )a  
        Implements complex algorithms that operate on strings.
        Right now the only algorithm implemented is the LCS algorithm
        (longest common substring). However new algorithms could be
        implemented in the future.

        ``algo`` Right now must be LCS
        ``value1`` and ``value2`` Can be two strings or two keys
        ``specific_argument`` Specifying if the arguments to the algorithm
        will be keys or strings. strings is the default.
        ``len`` Returns just the len of the match.
        ``idx`` Returns the match positions in each string.
        ``minmatchlen`` Restrict the list of matches to the ones of a given
        minimal length. Can be provided only when ``idx`` set to True.
        ``withmatchlen`` Returns the matches with the len of the match.
        Can be provided only when ``idx`` set to True.

        For more information see https://redis.io/commands/stralgo
        rq   Nr-  zdefault-node)popupdatesuperstralgo)r_   r.  r0  r1  r2  r3  r4  r5  r6  r   rq   	__class__s              rc   r;  z!ClusterDataAccessCommands.stralgo  sk    > zz.$7	)l.B)L~|45w

 

 
	
re   matchcount_typec           
   +   B  K    | j                   d|||d|\  }}|E d {    |j                         D ci c]  \  }}|dk7  s|| }}}|r|j                         D ci c]  }|| j                  |       }	}|j	                  dd        |ru|j                         D ]5  \  }} | j                   d|||||	|   d|\  }
}|E d {    |
|   ||<   7 |j                         D ci c]  \  }}|dk7  s|| }}}|rty y y 7 c c}}w c c}w 7 Jc c}}w wN)r=  r>  r?  r   )	node_namerq   )cursorr=  r>  r?  rq   r   scanrh   rX   get_noder8  )r_   r=  r>  r?  r   cursorsdatanamerC  nodescurs              rc   	scan_iterz#ClusterDataAccessCommands.scan_iter  sN     "		RU%R6R4;MMOSLD&vQR{4<SSEL\\^TTT4==4=88TET JJ~t,$+MMO 
.LD& )		 !%###%*4[! !!IC  $OO$'IGDM
. 6=]]_%1T6RSD&L    	S U $s]   DD
DDDD#D=ADD!D.D<DDDDD)r-  FFNFNNN)r   r   r   r   r   r   r   r   r   r   r'   r;  r   r   r   rL  __classcell__)r<  s   @rc   r+  r+    s     IR%)"-
en-
 -
 	-

 !!3WV_!DE-
 -
 -
 c]-
 -
 
-
b %)##	!!! }! }	! 
!re   r+  c            	       B    e Zd ZdZ	 	 	 ddee   dee   dee   defdZ	y)	AsyncClusterDataAccessCommandsr,  Nr=  r>  r?  rY   c           
     l  K    | j                   d|||d| d {   \  }}|D ]  }| 	 |j                         D 	ci c]  \  }}	|	dk7  s||	 }}}	|r|j                         D ci c]  }|| j                  |       }
}|j	                  dd        |r|j                         D ]?  \  }}	 | j                   d|	||||
|   d| d {   \  }}|D ]  }| 	 ||   ||<   A |j                         D 	ci c]  \  }}	|	dk7  s||	 }}}	|r~y y y 7 c c}	}w c c}w 7 Zc c}	}w wrA  rD  )r_   r=  r>  r?  r   rG  rH  valuerI  rC  rJ  rK  s               rc   rL  z(AsyncClusterDataAccessCommands.scan_iter?  sw     (diiXe5XQWXX 	EK	 5<MMOSLD&vQR{4<SSEL\\^TTT4==4=88TET JJ~t,$+MMO .LD&&/dii '%###%*4[' !' !IC "& $#$$'IGDM. 6=]]_%1T6RSD&L    Y T U!s^   D4D&D4D!D!D4-D'A
D4D,0D4D.D.D4D4!D4.D4rM  )
r   r   r   r   r   r   r   r   r   rL  r   re   rc   rP  rP  5  sJ     %)##	#!# }# }	# 
#re   rP  c                       e Zd ZdZy)RedisClusterCommands  
    A class for all Redis Cluster commands

    For key-based commands, the target node(s) will be internally determined
    by the keys' hash slot.
    Non-key-based commands can be executed with the 'target_nodes' argument to
    target specific nodes. By default, if target_nodes is not specified, the
    command will be executed on the default cluster node.

    :param :target_nodes: type can be one of the followings:
        - nodes flag: ALL_NODES, PRIMARIES, REPLICAS, RANDOM
        - 'ClusterNode'
        - 'list(ClusterNodes)'
        - 'dict(any:clusterNodes)'

    for example:
        r.cluster_info(target_nodes=RedisCluster.ALL_NODES)
    Nr   r   r   r   r   re   rc   rT  rT  e  s    re   rT  c                       e Zd ZdZy)AsyncRedisClusterCommandsrU  NrV  r   re   rc   rX  rX    s    re   rX  )<r%  typingr   r   r   r   r   r   r	   r
   r   r   r   redis.compatr   	redis.crcr   redis.exceptionsr   r   redis.typingr   r   r   r   r   r   corer   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   helpersr)   redismodulesr*   redis.asyncio.clusterr+   	frozensetrs   rV   r   r   r"  r+  rP  rT  rX  r   re   rc   <module>rc     s       !  >     $ " -2 *,^aA5 aAHL$#: L$^dM 2 dMN
6
6X 2 Xv-6-`@ ""re   