Ë
    êU.jsó  ã                   ó´  — U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZmZmZ d dlmZ d dlmZmZmZmZmZmZmZ d dlmZ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' d	dl(m)Z) d	dl*m+Z+m,Z, d	dl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 d	dl6m7Z7 d	dl8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ e:rd dlAZAdZBdZCdZDdZEdZF eG«       ZHeee&e'e%f      eId<   e:re%ZJne&ZJ G d„ d«      ZK G d„ d«      ZL G d„ d«      ZM G d„ deM«      ZN G d„ deN«      ZO G d „ d!eM«      ZP G d"„ d#eO«      ZQ G d$„ d%eN«      ZRd&ZSd'„ ZTeUeVeVeTeTeWeUeUeTeVd(œ
ZXd)„ ZY G d*„ d+«      ZZ G d,„ d-eZ«      Z[y).é    N)Úabstractmethod)Úchain)ÚEmptyÚFullÚ	LifoQueue)Útime)ÚAnyÚCallableÚDictÚListÚOptionalÚTypeÚUnion)Úparse_qsÚunquoteÚurlparse)Ú
CacheEntryÚCacheEntryStatusÚCacheFactoryÚCacheFactoryInterfaceÚCacheInterfaceÚCacheKeyé   )ÚEncoderÚ_HiredisParserÚ_RESP2ParserÚ_RESP3Parser)Ú	NoBackoff)ÚCredentialProviderÚ"UsernamePasswordCredentialProvider)ÚAuthenticationErrorÚ$AuthenticationWrongNumberOfArgsErrorÚChildDeadlockedErrorÚConnectionErrorÚ	DataErrorÚ
RedisErrorÚResponseErrorÚTimeoutError)ÚRetry)ÚCRYPTOGRAPHY_AVAILABLEÚHIREDIS_AVAILABLEÚSSL_AVAILABLEÚcompare_versionsÚensure_stringÚformat_error_messageÚget_lib_versionÚstr_if_bytesó   *ó   $s   
ó    é   ÚDefaultParserc                   ó   — e Zd Zdefd„Zy)ÚHiredisRespSerializerÚargsc                 ó¬  — g }t        |d   t        «      r1t        |d   j                  «       j	                  «       «      |dd z   }n)d|d   v r"t        |d   j	                  «       «      |dd z   }	 |j                  t        j                  |«      «       |S # t        $ r3 t        j                  «       \  }}}t        |«      j                  |«      ‚w xY w©ú2Pack a series of arguments into the Redis protocolr   r   Nó    )Ú
isinstanceÚstrÚtupleÚencodeÚsplitÚappendÚhiredisÚpack_commandÚ	TypeErrorÚsysÚexc_infor%   Úwith_traceback)Úselfr9   ÚoutputÚ_ÚvalueÚ	tracebacks         úRC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\redis/connection.pyÚpackzHiredisRespSerializer.packE   sÄ   € àˆä�d˜1‘gœsÔ#Ü˜˜a™Ÿ™Ó)×/Ñ/Ó1Ó2°T¸!¸"°XÑ=‰DØ�T˜!‘W‰_Ü˜˜a™Ÿ™›Ó)¨D°°¨HÑ4ˆDð	=Ø�M‰Mœ'×.Ñ.¨tÓ4Ô5ð
 ˆøô	 ò 	=Ü"%§,¡,£.ÑˆAˆu�iÜ˜EÓ"×1Ñ1°)Ó<Ð<ð	=ús   Á1$B Â<CN)Ú__name__Ú
__module__Ú__qualname__r   rP   © r4   rO   r8   r8   D   s   „ ð˜$ô r4   r8   c                   ó   — e Zd Zdd„Zd„ Zy)ÚPythonRespSerializerNc                 ó    — || _         || _        y ©N)Ú_buffer_cutoffrA   )rJ   Úbuffer_cutoffrA   s      rO   Ú__init__zPythonRespSerializer.__init__W   s   € Ø+ˆÔØˆ�r4   c           	      ón  — g }t        |d   t        «      r1t        |d   j                  «       j	                  «       «      |dd z   }n)d|d   v r"t        |d   j	                  «       «      |dd z   }t
        j                  t        t        t        |«      «      j                  «       t        f«      }| j                  }t        | j                  |«      D ]Ï  }t        |«      }t        |«      |kD  s||kD  st        |t        «      rat
        j                  |t        t        |«      j                  «       t        f«      }|j                  |«       |j                  |«       t        }Œ’t
        j                  |t        t        |«      j                  «       t        |t        f«      }ŒÑ |j                  |«       |S r;   )r>   r?   r@   rA   rB   Ú	SYM_EMPTYÚjoinÚSYM_STARÚlenÚSYM_CRLFrY   ÚmapÚ
memoryviewÚ
SYM_DOLLARrC   )rJ   r9   rK   ÚbuffrZ   ÚargÚ
arg_lengths          rO   rP   zPythonRespSerializer.pack[   sd  € àˆô �d˜1‘gœsÔ#Ü˜˜a™Ÿ™Ó)×/Ñ/Ó1Ó2°T¸!¸"°XÑ=‰DØ�T˜!‘W‰_Ü˜˜a™Ÿ™›Ó)¨D°°¨HÑ4ˆDä�~‰~œx¬¬S°«Y«×)>Ñ)>Ó)@Ä(ÐKÓLˆà×+Ñ+ˆÜ�t—{‘{ DÖ)ˆCô ˜S›ˆJä�D“	˜MÒ)Ø Ò-Ü˜c¤:Ô.ä —~‘~Øœ:¤s¨:£×'=Ñ'=Ó'?ÄÐJó�ð —‘˜dÔ#Ø—‘˜cÔ"Ü‘ä —~‘~àÜ"Ü˜J›×.Ñ.Ó0Ü ØÜ ðó	‘ð! *ð4 	�‰�dÔØˆr4   ©ÚreturnN)rQ   rR   rS   r[   rP   rT   r4   rO   rV   rV   V   s   „ óó+r4   rV   c                   ó:  — e Zd Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zedd
„«       Zed„ «       Zedd„«       Ze	 dd	ddœd„«       Zed„ «       Zed„ «       Zeedeeeef   eeef   f   fd„«       «       Zy)ÚConnectionInterfacec                  ó   — y rX   rT   ©rJ   s    rO   Úrepr_pieceszConnectionInterface.repr_piecesŠ   ó   € àr4   c                  ó   — y rX   rT   ©rJ   Úcallbacks     rO   Úregister_connect_callbackz-ConnectionInterface.register_connect_callbackŽ   ro   r4   c                  ó   — y rX   rT   rq   s     rO   Úderegister_connect_callbackz/ConnectionInterface.deregister_connect_callback’   ro   r4   c                  ó   — y rX   rT   ©rJ   Úparser_classs     rO   Ú
set_parserzConnectionInterface.set_parser–   ro   r4   c                  ó   — y rX   rT   rm   s    rO   ÚconnectzConnectionInterface.connectš   ro   r4   c                  ó   — y rX   rT   rm   s    rO   Ú
on_connectzConnectionInterface.on_connectž   ro   r4   c                  ó   — y rX   rT   ©rJ   r9   s     rO   Ú
disconnectzConnectionInterface.disconnect¢   ro   r4   c                  ó   — y rX   rT   rm   s    rO   Úcheck_healthz ConnectionInterface.check_health¦   ro   r4   Tc                  ó   — y rX   rT   ©rJ   Úcommandr‚   s      rO   Úsend_packed_commandz'ConnectionInterface.send_packed_commandª   ro   r4   c                  ó   — y rX   rT   ©rJ   r9   Úkwargss      rO   Úsend_commandz ConnectionInterface.send_command®   ro   r4   c                  ó   — y rX   rT   ©rJ   Útimeouts     rO   Úcan_readzConnectionInterface.can_read²   ro   r4   F©Údisconnect_on_errorÚpush_requestc                 ó   — y rX   rT   )rJ   Údisable_decodingr�   r‘   s       rO   Úread_responsez!ConnectionInterface.read_response¶   s   € ð 	r4   c                  ó   — y rX   rT   r   s     rO   rE   z ConnectionInterface.pack_commandÀ   ro   r4   c                  ó   — y rX   rT   ©rJ   Úcommandss     rO   Úpack_commandsz!ConnectionInterface.pack_commandsÄ   ro   r4   ri   c                  ó   — y rX   rT   rm   s    rO   Úhandshake_metadataz&ConnectionInterface.handshake_metadataÈ   s   € ð 	r4   N©T©r   ©F)rQ   rR   rS   r   rn   rs   ru   ry   r{   r}   r€   r‚   r†   rŠ   rŽ   r”   rE   r™   Úpropertyr   r   Úbytesr?   r›   rT   r4   rO   rk   rk   ‰   sh  „ Øñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð òó ðð ñó ðð òó ðð ð ðð !Øóó ðð ñó ðð ñó ðð Øð E¨$¨u°e¨|Ñ*<¸dÀ3ÈÀ8¹nÐ*LÑ$Mò ó ó ñr4   rk   c            *       ó<  — e Zd ZdZdddddedddedddd e«       ddddd	dfd
edee	   dee
   dee
   dede	de	dedededee	   dee	   dee	   dee	   deedf   deeg df      dee   dee   deeg df      f&d„Zd„ Zed„ «       Zd „ Zd!„ Zd"„ Zd#„ Zd$„ Zd%„ Zed&„ «       Zed'„ «       Zd(„ Zd)„ Zd*„ Zd+„ Zd,„ Z d-„ Z!d;d/„Z"d0„ Z#d<d1„Z$	 d=d.dd2œd3„Z%d4„ Z&d5„ Z'd6exs e	fd7„Z(e)d6ee*e+e+f   e*e	e	f   f   fd8„«       Z,e,jZ                  d9ee*e+e+f   e*e	e	f   f   fd:„«       Z,y)>ÚAbstractConnectionz0Manages communication to and from a Redis serverr   NFúutf-8Ústricti   zredis-pyr5   ÚdbÚpasswordÚsocket_timeoutÚsocket_connect_timeoutÚretry_on_timeoutÚencodingÚencoding_errorsÚdecode_responsesÚsocket_read_sizeÚhealth_check_intervalÚclient_nameÚlib_nameÚlib_versionÚusernameÚretryÚredis_connect_funcÚcredential_providerÚprotocolÚcommand_packerc                 óÞ  — |s|r|�t        d«      ‚t        j                  «       | _        || _        || _        || _        || _        || _        || _	        || _
        || _        |€|}|| _        || _        |t        u rg }|r|j                  t         «       || _        |s|rR|€t%        t'        «       d«      | _        nt+        j,                  |«      | _        | j(                  j/                  |«       nt%        t'        «       d«      | _        || _        d| _        || _        t7        |||	«      | _        d| _        d| _        || _        | jA                  |
«       g | _!        d| _"        	 tG        |«      }|dk  s|dkD  rtO        d	«      ‚|| _(        | jS                  |«      | _*        y# tH        $ r	 tJ        }Y ŒDtL        $ r tO        d«      ‚w xY w# dk  s|dkD  rtO        d	«      ‚|| _(        w xY w)
a2  
        Initialize a new Connection.
        To specify a retry policy for specific errors, first set
        `retry_on_error` to a list of the error/s to retry on, then set
        `retry` to a valid `Retry` object.
        To retry on TimeoutError, `retry_on_timeout` can also be set to `True`.
        NzÂ'username' and 'password' cannot be passed along with 'credential_provider'. Please provide only one of the following arguments: 
1. 'password' and (optional) 'username'
2. 'credential_provider'r   r   ip  zprotocol must be an integerr5   é   zprotocol must be either 2 or 3)+r%   ÚosÚgetpidÚpidr¥   r¯   r°   r±   rµ   r¦   r²   r§   r¨   r©   ÚSENTINELrC   r(   Úretry_on_errorr)   r   r³   ÚcopyÚdeepcopyÚupdate_supported_errorsr®   Únext_health_checkr´   r   Úencoderr›   Ú_sockÚ_socket_read_sizery   Ú_connect_callbacksrY   ÚintrF   ÚDEFAULT_RESP_VERSIONÚ
ValueErrorr$   r¶   Ú_construct_command_packerÚ_command_packer)rJ   r¥   r¦   r§   r¨   r©   r¾   rª   r«   r¬   rx   r­   r®   r¯   r°   r±   r²   r³   r´   rµ   r¶   r·   Úps                          rO   r[   zAbstractConnection.__init__Ñ   sê  € ñ> ™Ð&9Ð&EÜð+óð ô —9‘9“;ˆŒØˆŒØ&ˆÔØ ˆŒØ&ˆÔØ#6ˆÔ Ø ˆŒØ ˆŒØ,ˆÔØ!Ð)Ø%3Ð"Ø&<ˆÔ#Ø 0ˆÔØœXÑ%ØˆNÙà×!Ñ!¤,Ô/Ø,ˆÔÙ‘NØˆ}Ü"¤9£;°Ó2�•
ô "Ÿ]™]¨5Ó1�”
à�J‰J×.Ñ.¨~Õ>äœy›{¨AÓ.ˆDŒJØ%:ˆÔ"Ø!"ˆÔØ"4ˆÔÜ˜x¨Ð:JÓKˆŒØ"&ˆÔØˆŒ
Ø!1ˆÔØ�‰˜Ô%Ø"$ˆÔØ"ˆÔð
	Ü�H“ˆAð �1Šu˜˜AšÜ%Ð&FÓGÐGàˆDŒMØ#×=Ñ=¸nÓMˆÕøô ò 	%Ü$ŠAÜò 	AÜ!Ð"?Ó@Ð@ð	Aûð �1Šu˜˜AšÜ%Ð&FÓGÐGàˆD�Mús$   Å(F& Æ&GÆ5G Æ7GÇG ÇG,c           	      óä   — dj                  | j                  «       D ��cg c]  \  }}|› d|› �‘Œ c}}«      }d| j                  j                  › d| j                  j                  › d|› d�S c c}}w )NÚ,Ú=Ú<Ú.Ú(ú)>)r^   rn   Ú	__class__rR   rQ   )rJ   ÚkÚvÚ	repr_argss       rO   Ú__repr__zAbstractConnection.__repr__+  sp   € Ø—H‘H°T×5EÑ5EÔ5GÔHÑ5G©T¨Q°   1 Q CšjÐ5GÒHÓIˆ	Ø�4—>‘>×,Ñ,Ð-¨Q¨t¯~©~×/FÑ/FÐ.GÀqÈÈÐSUÐVÐVùó Is   ŸA,
c                  ó   — y rX   rT   rm   s    rO   rn   zAbstractConnection.repr_pieces/  ro   r4   c                 óD   — 	 | j                  «        y # t        $ r Y y w xY wrX   )r€   Ú	Exceptionrm   s    rO   Ú__del__zAbstractConnection.__del__3  s#   € ð	Ø�O‰OÕøÜò 	Ùð	ús   ‚ “	žc                 ó~   — |�|S t         r
t        «       S t        | j                  | j                  j
                  «      S rX   )r+   r8   rV   rY   rÃ   rA   )rJ   Úpackers     rO   rÊ   z,AbstractConnection._construct_command_packer9  s6   € ØÐØˆMÝÜ(Ó*Ð*ä'¨×(;Ñ(;¸T¿\¹\×=PÑ=PÓQÐQr4   c                 ó‚   — t        j                  |«      }|| j                  vr| j                  j                  |«       yy)a^  
        Register a callback to be called when the connection is established either
        initially or reconnected.  This allows listeners to issue commands that
        are ephemeral to the connection, for example pub/sub subscription or
        key tracking.  The callback must be a _method_ and will be kept as
        a weak reference.
        N)ÚweakrefÚ
WeakMethodrÆ   rC   )rJ   rr   Úwms      rO   rs   z,AbstractConnection.register_connect_callbackA  s;   € ô ×Ñ Ó)ˆØ�T×,Ñ,Ñ,Ø×#Ñ#×*Ñ*¨2Õ.ð -r4   c                 ó€   — 	 | j                   j                  t        j                  |«      «       y# t        $ r Y yw xY w)z÷
        De-register a previously registered callback.  It will no-longer receive
        notifications on connection events.  Calling this is not required when the
        listener goes away, since the callbacks are kept as weak methods.
        N)rÆ   Úremoverà   rá   rÉ   rq   s     rO   ru   z.AbstractConnection.deregister_connect_callbackM  s8   € ð	Ø×#Ñ#×*Ñ*¬7×+=Ñ+=¸hÓ+GÕHøÜò 	Ùð	ús   ‚.1 ±	=¼=c                 ó4   —  || j                   ¬«      | _        y)zË
        Creates a new instance of parser_class with socket size:
        _socket_read_size and assigns it to the parser for the connection
        :param parser_class: The required parser class
        )r­   N)rÅ   Ú_parserrw   s     rO   ry   zAbstractConnection.set_parserX  s   € ñ $°T×5KÑ5KÔLˆ�r4   c                 ó<  ‡ — ‰ j                   ry	 ‰ j                  j                  ˆ fd„ˆ fd„«      }|‰ _         	 ‰ j                  €‰ j                  «        n‰ j                  ‰ «       ‰ j                  D �cg c]  } |«       sŒ|‘Œ c}‰ _        ‰ j                  D ]  } |«       }|sŒ |‰ «       Œ y# t        j                  $ r t        d«      ‚t        $ r}t        ‰ j                  |«      «      ‚d}~ww xY w# t        $ r ‰ j                  «        ‚ w xY wc c}w )z5Connects to the Redis server if not already connectedNc                  ó$   •— ‰ j                  «       S rX   )Ú_connectrm   s   €rO   Ú<lambda>z,AbstractConnection.connect.<locals>.<lambda>f  s   ø€ ˜Ÿ™œr4   c                 ó&   •— ‰j                  | «      S rX   ©r€   )ÚerrorrJ   s    €rO   rê   z,AbstractConnection.connect.<locals>.<lambda>f  s   ø€ °t·±ÀuÔ7Mr4   zTimeout connecting to server)rÄ   r³   Úcall_with_retryÚsocketr�   r(   ÚOSErrorr$   Ú_error_messager´   r}   r&   r€   rÆ   )rJ   ÚsockÚeÚrefrr   s   `    rO   r{   zAbstractConnection.connect`  s  ø€ à�:Š:Øð	:Ø—:‘:×-Ñ-Û'Ó)MóˆDð ˆŒ
ð
	Ø×&Ñ&Ð.à—‘Õ!ð ×'Ñ'¨Ô-ð 37×2IÒ2IÓ"SÑ2I¨3ÉSÍU¢3Ð2IÑ"SˆÔØ×*Ô*ˆCÙ“uˆHÚÙ˜•ñ +øô- �~‰~ò 	?ÜÐ=Ó>Ð>Üò 	:Ü! $×"5Ñ"5°aÓ"8Ó9Ð9ûð	:ûô ò 	à�O‰OÔØð	üò #Ts.   �"B3 º.C; Á6DÂDÂ3&C8ÃC3Ã3C8Ã;Dc                  ó   — y rX   rT   rm   s    rO   ré   zAbstractConnection._connectƒ  ro   r4   c                  ó   — y rX   rT   rm   s    rO   Ú_host_errorzAbstractConnection._host_error‡  ro   r4   c                 ó6   — t        | j                  «       |«      S rX   )r/   r÷   )rJ   Ú	exceptions     rO   rñ   z!AbstractConnection._error_message‹  s   € Ü# D×$4Ñ$4Ó$6¸	ÓBÐBr4   c                 óô  — | j                   j                  | «       | j                   }d}| j                  s| j                  s| j                  r>| j                  xs  t        | j                  | j                  «      }|j                  «       }|r¾| j                  dvr°t        | j                   t        «      rK| j                  t        «       |j                  | j                   _        | j                   j                  | «       t        |«      dk(  rd|d   g} | j                  d| j                  dg|¢­Ž  | j                  «       | _        �nB|rA | j                  dg|¢­dd	iŽ 	 | j                  «       }t%        |«      dk7  �r
t'        d«      ‚| j                  dvrñt        | j                   t        «      rK| j                  t        «       |j                  | j                   _        | j                   j                  | «       | j                  d| j                  «       | j                  «       | _        | j                   j)                  d«      | j                  k7  r3| j                   j)                  d«      | j                  k7  rt+        d«      ‚| j,                  rD| j                  dd| j,                  «       t%        | j                  «       «      dk7  rt+        d«      ‚	 | j.                  r.| j                  ddd| j.                  «       | j                  «        	 | j2                  r.| j                  ddd| j2                  «       | j                  «        | j4                  rD| j                  d| j4                  «       t%        | j                  «       «      dk7  rt+        d«      ‚yy# t"        $ r+ | j                  d|d
   d	¬«       | j                  «       }Y �Œcw xY w# t0        $ r Y ŒÎw xY w# t0        $ r Y Œ¢w xY w)z=Initialize the connection, authenticate and select a databaseN)r5   Ú2r   Údefaultr   ÚHELLOÚAUTHr‚   Féÿÿÿÿ©r‚   ÚOKzInvalid Username or Passwords   protoÚprotozInvalid RESP versionÚCLIENTÚSETNAMEzError setting client nameÚSETINFOzLIB-NAMEzLIB-VERÚSELECTzInvalid Database)ræ   r}   rµ   r²   r¦   r    Úget_credentialsr¶   r>   r   ry   r   ÚEXCEPTION_CLASSESr`   rŠ   r”   r›   r"   r1   r!   Úgetr$   r¯   r°   r'   r±   r¥   )rJ   ÚparserÚ	auth_argsÚcred_providerÚauth_responses        rO   r}   zAbstractConnection.on_connectŽ  s]  € à�‰×Ñ Ô%Ø—‘ˆàˆ	à×#Ò#¨¯ª¸¿ºà×(Ñ(ò TÜ5°d·m±mÀTÇ]Á]ÓSð ð &×5Ñ5Ó7ˆIñ ˜Ÿ™¨hÑ6Ü˜$Ÿ,™,¬Ô5Ø—‘¤Ô-à17×1IÑ1I�—‘Ô.Ø—‘×'Ñ'¨Ô-Ü�9‹~ Ò"Ø&¨	°!©Ð5�	ØˆD×Ñ˜g t§}¡}°fÐI¸yÓIØ&*×&8Ñ&8Ó&:ˆDÖ#ñ
 ð ˆD×Ñ˜fÐE yÒE¸uÒEð5Ø $× 2Ñ 2Ó 4�ô ˜MÓ*¨dÓ2Ü)Ð*HÓIÐIð �]‰] (Ñ*Ü˜$Ÿ,™,¬Ô5Ø—‘¤Ô-à17×1IÑ1I�—‘Ô.Ø—‘×'Ñ'¨Ô-Ø×Ñ˜g t§}¡}Ô5Ø&*×&8Ñ&8Ó&:ˆDÔ#à×'Ñ'×+Ñ+¨HÓ5¸¿¹ÒFØ×+Ñ+×/Ñ/°Ó8¸D¿M¹MÒIä%Ð&<Ó=Ð=ð ×ÒØ×Ñ˜h¨	°4×3CÑ3CÔDÜ˜D×.Ñ.Ó0Ó1°TÒ9Ü%Ð&AÓBÐBð	à�}Š}Ø×!Ñ! (¨I°zÀ4Ç=Á=ÔQØ×"Ñ"Ô$ð	Ø×ÒØ×!Ñ! (¨I°yÀ$×BRÑBRÔSØ×"Ñ"Ô$ð
 �7Š7Ø×Ñ˜h¨¯©Ô0Ü˜D×.Ñ.Ó0Ó1°TÒ9Ü%Ð&8Ó9Ð9ð :ð øôa 8ò 5ð
 ×!Ñ! &¨)°B©-ÀeÐ!ÔLØ $× 2Ñ 2Ó 4“ð5ûôJ ò 	Ùð	ûô ò 	Ùð	ús6   Å%N% Ë:O Ì:O+ Î%0OÏOÏ	O(Ï'O(Ï+	O7Ï6O7c                 óP  — | j                   j                  «        | j                  }d| _        |€yt        j                  «       | j
                  k(  r 	 |j                  t        j                  «       	 |j                  «        y# t        t        f$ r Y Œ#w xY w# t        $ r Y yw xY w)z!Disconnects from the Redis serverN)ræ   Úon_disconnectrÄ   rº   r»   r¼   Úshutdownrï   Ú	SHUT_RDWRrð   rF   Úclose)rJ   r9   Ú	conn_socks      rO   r€   zAbstractConnection.disconnectè  s‘   € à�‰×"Ñ"Ô$à—J‘Jˆ	ØˆŒ
ØÐØä�9‰9‹;˜$Ÿ(™(Ò"ðØ×"Ñ"¤6×#3Ñ#3Ô4ð	Ø�O‰OÕøô	 œYÐ'ò Ùðûô
 ò 	Ùð	ús$   ÁB Á3B ÂBÂBÂ	B%Â$B%c                 óx   — | j                  dd¬«       t        | j                  «       «      dk7  rt        d«      ‚y)z Send PING, expect PONG in returnÚPINGFr   ÚPONGz#Bad response from PING health checkN)rŠ   r1   r”   r$   rm   s    rO   Ú
_send_pingzAbstractConnection._send_pingü  s<   € à×Ñ˜&¨uÐÔ5Ü˜×*Ñ*Ó,Ó-°Ò7Ü!Ð"GÓHÐHð 8r4   c                 ó$   — | j                  «        y)z Function to call when PING failsNrì   )rJ   rí   s     rO   Ú_ping_failedzAbstractConnection._ping_failed  ó   € à�‰Õr4   c                 ó®   — | j                   rIt        «       | j                  kD  r1| j                  j	                  | j
                  | j                  «       yyy)z3Check the health of the connection with a PING/PONGN)r®   r   rÂ   r³   rî   r  r  rm   s    rO   r‚   zAbstractConnection.check_health  sA   € à×%Ò%¬$«&°4×3IÑ3IÒ*IØ�J‰J×&Ñ& t§¡¸×8IÑ8IÕJð +JÐ%r4   Tc                 óN  — | j                   s| j                  «        |r| j                  «        	 t        |t        «      r|g}|D ]  }| j                   j                  |«       Œ y# t        j                  $ r | j                  «        t        d«      ‚t        $ ro}| j                  «        t        |j                  «      dk(  rd|j                  d   }}n|j                  d   }|j                  d   }t        d|› d|› d�«      ‚d}~wt        $ r | j                  «        ‚ w xY w)	z2Send an already packed command to the Redis serverzTimeout writing to socketr   ÚUNKNOWNr   zError z while writing to socket. rÑ   N)rÄ   r{   r‚   r>   r?   Úsendallrï   r�   r€   r(   rð   r`   r9   r$   ÚBaseException)rJ   r…   r‚   Úitemró   ÚerrnoÚerrmsgs          rO   r†   z&AbstractConnection.send_packed_command  sþ   € à�zŠzØ�L‰LŒNáØ×ÑÔð	Ü˜'¤3Ô'Ø"˜)�Û�Ø—
‘
×"Ñ" 4Õ(ñ  øä�~‰~ò 	<Ø�O‰OÔÜÐ:Ó;Ð;Üò 	WØ�O‰OÔÜ�1—6‘6‹{˜aÒØ )¨1¯6©6°!©9�v‘àŸ™˜q™	�ØŸ™ ™�Ü! F¨5¨'Ð1KÈFÈ8ÐSTÐ"UÓVÐVûÜò 	ð
 �O‰OÔØð	ús   °5A& Á&6D$ÂA*DÄD$c                 óx   — | j                   | j                  j                  |Ž |j                  dd«      ¬«       y)z+Pack and send a command to the Redis serverr‚   Tr   N)r†   rË   rP   r	  rˆ   s      rO   rŠ   zAbstractConnection.send_command*  s9   € à× Ñ Ø%ˆD× Ñ ×%Ñ% tÐ,ØŸ™ N°DÓ9ð 	!õ 	
r4   c                 ó  — | j                   }|s| j                  «        | j                  «       }	 | j                  j	                  |«      S # t
        $ r0}| j                  «        t        d|› d|j                  › �«      ‚d}~ww xY w)z8Poll the socket to see if there's data that can be read.úError while reading from z: N)	rÄ   r{   r÷   ræ   rŽ   rð   r€   r$   r9   )rJ   r�   rò   Ú
host_errorró   s        rO   rŽ   zAbstractConnection.can_read1  sy   € à�z‰zˆÙØ�L‰LŒNà×%Ñ%Ó'ˆ
ð	VØ—<‘<×(Ñ(¨Ó1Ð1øÜò 	VØ�O‰OÔÜ!Ð$=¸j¸\ÈÈAÏFÉFÈ8Ð"TÓUÐUûð	Vús   °A Á	BÁ+A?Á?Br�   c                ó\  — | j                  «       }	 | j                  dv r$t        s| j                  j	                  ||¬«      }n| j                  j	                  |¬«      }| j                  rt        «       | j                  z   | _        t!        |t"        «      r	 |‚|S # t
        j                  $ r! |r| j                  «        t        d|› �«      ‚t        $ r2}|r| j                  «        t        d|› d|j                  › �«      ‚d}~wt        $ r |r| j                  «        ‚ w xY w# ~w xY w)z0Read the response from a previously sent command)Ú3r¹   )r“   r‘   )r“   zTimeout reading from r%  z : N)r÷   r¶   r+   ræ   r”   rï   r�   r€   r(   rð   r$   r9   r  r®   r   rÂ   r>   r'   )rJ   r“   r�   r‘   r&  Úresponseró   s          rO   r”   z AbstractConnection.read_response?  s(  € ð ×%Ñ%Ó'ˆ
ð	Ø�}‰} Ñ(Õ1BØŸ<™<×5Ñ5Ø%5ÀLð 6ó ‘ð  Ÿ<™<×5Ñ5ÐGWÐ5ÓX�ð& ×%Ò%Ü%)£V¨d×.HÑ.HÑ%HˆDÔ"ä�h¤Ô.ðØ�ð ˆøô5 �~‰~ò 	EÙ"Ø—‘Ô!ÜÐ!6°z°lÐCÓDÐDÜò 	Ù"Ø—‘Ô!Ü!Ø+¨J¨<¸3¸q¿v¹v¸hÐGóð ûô ò 	ñ #Ø—‘Ô!Øð	ûñ ús$   ’AB ÂD( Â;D%Ã-DÄ D%Ä(D+c                 ó4   —  | j                   j                  |Ž S )r<   )rË   rP   r   s     rO   rE   zAbstractConnection.pack_commandm  s   € à(ˆt×#Ñ#×(Ñ(¨$Ð/Ð/r4   c                 óØ  — g }g }d}| j                   }|D ]¬  } | j                  j                  |Ž D ]Ž  }t        |«      }||kD  s||kD  st	        |t
        «      r*|r$|j                  t        j                  |«      «       d}g }||kD  st	        |t
        «      r|j                  |«       Œy|j                  |«       ||z  }Œ� Œ® |r$|j                  t        j                  |«      «       |S )z.Pack multiple commands into the Redis protocolr   )	rY   rË   rP   r`   r>   rc   rC   r]   r^   )	rJ   r˜   rK   ÚpiecesÚbuffer_lengthrZ   ÚcmdÚchunkÚchunklens	            rO   r™   z AbstractConnection.pack_commandsq  sÚ   € àˆØˆØˆØ×+Ñ+ˆãˆCØ2˜×-Ñ-×2Ñ2°CÓ8�Ü˜u›:�à! MÒ1Ø -Ò/Ü! %¬Ô4áØŸ™¤i§n¡n°VÓ&<Ô=Ø$%�MØ�Fà˜mÒ+¬z¸%ÄÔ/LØ—M‘M %Õ(à—M‘M %Ô(Ø! XÑ-‘Mñ! 9ð ñ& Ø�M‰Mœ)Ÿ.™.¨Ó0Ô1Øˆr4   ri   c                 ó   — | j                   S rX   )r¶   rm   s    rO   Úget_protocolzAbstractConnection.get_protocol�  s   € Ø�}‰}Ðr4   c                 ó   — | j                   S rX   ©Ú_handshake_metadatarm   s    rO   r›   z%AbstractConnection.handshake_metadata’  s   € à×'Ñ'Ð'r4   rM   c                 ó   — || _         y rX   r4  )rJ   rM   s     rO   r›   z%AbstractConnection.handshake_metadata–  s
   € à#(ˆÕ r4   rœ   r�   rž   ).rQ   rR   rS   Ú__doc__r½   r6   r0   rÇ   r   r?   ÚfloatÚboolr   r	   r
   r   r[   rØ   r   rn   rÜ   rÊ   rs   ru   ry   r{   ré   r÷   rñ   r}   r€   r  r  r‚   r†   rŠ   rŽ   r”   rE   r™   r2  rŸ   r   r    r›   ÚsetterrT   r4   rO   r¢   r¢   Î   s¸  „ Ù6ð Ø"&Ø*.Ø26Ø!&ØØØ'Ø!&Ø"Ø %Ø%&Ø%)Ø",Ù%4Ó%6Ø"&Ø"&Ø;?Ø<@Ø"#Ø7;ñ-XNàðXNð ˜3‘-ðXNð ! ™ð	XNð
 !)¨¡ðXNð ðXNð ðXNð ðXNð ðXNð ðXNð  #ðXNð ˜c‘]ðXNð ˜3‘-ðXNð  ˜c‘]ð!XNð" ˜3‘-ð#XNð$ �S˜$�YÑð%XNð& % X¨b°$¨hÑ%7Ñ8ð'XNð( &Ð&8Ñ9ð)XNð* ˜3‘-ð+XNð, ! ¨"¨d¨(Ñ!3Ñ4ó-XNòtWð ñó ðòòRò
/ò	òMò!ðF ñó ðð ñó ðòCòX:òtò(IòòKó
ò>
óVð  ð,ð !Øô,ò\0òð<˜cšj Só ð ð( E¨$¨u°e¨|Ñ*<¸dÀ3ÈÀ8¹nÐ*LÑ$Mò (ó ð(ð ×Ñð)¨¨d°5¸%°<Ñ.@À$ÀsÈCÀxÁ.Ð.PÑ(Qò )ó ñ)r4   r¢   c                   ó@   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zd„ Zd„ Zd„ Zˆ xZS )Ú
Connectionz4Manages TCP communication to and from a Redis serverc                 ó„   •— || _         t        |«      | _        || _        |xs i | _        || _        t        ‰| �  di |¤Ž y ©NrT   )ÚhostrÇ   ÚportÚsocket_keepaliveÚsocket_keepalive_optionsÚsocket_typeÚsuperr[   )rJ   r?  r@  rA  rB  rC  r‰   rÔ   s          €rO   r[   zConnection.__init__ž  sD   ø€ ð ˆŒ	Ü˜“IˆŒ	Ø 0ˆÔØ(@Ò(FÀBˆÔ%Ø&ˆÔÜ‰ÑÑ"˜6Ó"r4   c                 óª   — d| j                   fd| j                  fd| j                  fg}| j                  r|j	                  d| j                  f«       |S )Nr?  r@  r¥   r¯   )r?  r@  r¥   r¯   rC   ©rJ   r,  s     rO   rn   zConnection.repr_pieces®  sM   € Ø˜4Ÿ9™9Ð%¨°·	±	Ð':¸TÀ4Ç7Á7¸OÐLˆØ×ÒØ�M‰M˜=¨$×*:Ñ*:Ð;Ô<Øˆr4   c                 ó@  — d}t        j                  | j                  | j                  | j                  t         j
                  «      D �]  }|\  }}}}}d}	 t        j                   |||«      }|j                  t         j                  t         j                  d«       | j                  rr|j                  t         j                  t         j                  d«       | j                  j                  «       D ]&  \  }	}
|j                  t         j                  |	|
«       Œ( |j                  | j                  «       |j!                  |«       |j                  | j"                  «       |c S  |�|‚t%        d«      ‚# t$        $ r}|}|�|j'                  «        Y d}~�ŒQd}~ww xY w)zCreate a TCP socket connectionNr   z)socket.getaddrinfo returned an empty list)rï   Úgetaddrinfor?  r@  rC  ÚSOCK_STREAMÚ
setsockoptÚIPPROTO_TCPÚTCP_NODELAYrA  Ú
SOL_SOCKETÚSO_KEEPALIVErB  ÚitemsÚ
settimeoutr¨   r{   r§   rð   r  )rJ   ÚerrÚresÚfamilyÚsocktyper  Ú	canonnameÚsocket_addressrò   rÕ   rÖ   rL   s               rO   ré   zConnection._connect´  s\  € ð
 ˆÜ×%Ñ%Ø�I‰I�t—y‘y $×"2Ñ"2´F×4FÑ4F÷
ˆCð BEÑ>ˆF�H˜e Y°ØˆDð!Ü—}‘} V¨X°uÓ=�à—‘¤× 2Ñ 2´F×4FÑ4FÈÔJð ×(Ò(Ø—O‘O¤F×$5Ñ$5´v×7JÑ7JÈAÔNØ $× =Ñ =× CÑ CÖ E™˜˜1ØŸ™¬×(:Ñ(:¸A¸qÕAð !Fð —‘ × ;Ñ ;Ô<ð —‘˜^Ô,ð —‘ × 3Ñ 3Ô4Ø’ð1
ð> ˆ?ØˆIÜÐAÓBÐBøô ò !Ø�ØÐ#Ø—J‘J”Lÿùð!ús   ÁDE5Å5	FÅ>FÆFc                 ó8   — | j                   › d| j                  › �S )NÚ:)r?  r@  rm   s    rO   r÷   zConnection._host_errorÝ  s   € Ø—)‘)�˜A˜dŸi™i˜[Ð)Ð)r4   )Ú	localhostië  FNr   ©	rQ   rR   rS   r7  r[   rn   ré   r÷   Ú__classcell__©rÔ   s   @rO   r<  r<  ›  s-   ø„ Ù:ð ØØØ!%Øõ#ò ò'CöR*r4   r<  c                   ó"  — e Zd ZdZdZdZdededej                  fd„Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd"d„Zd„ Zd#d„Z	 d$dddœd„Zd„ Zd„ Zedeeeef   eeef   f   fd„«       Zd„ Zd„ Z deddfd„Z!d„ Z"d e#eee$e#e      f      fd!„Z%y)%ÚCacheProxyConnections   fooz7.4.0ÚredisÚconnÚcacheÚ	pool_lockc                 ó†  — t        j                  «       | _        || _        | j                  j                  | _        | j                  j
                  | _        | j                  j                  | _        || _        || _        t        j                  «       | _        d | _        d | _        | j                  | j                  «       y rX   )rº   r»   r¼   Ú_connr³   r?  r@  Ú
_pool_lockÚ_cacheÚ	threadingÚLockÚ_cache_lockÚ_current_command_cache_keyÚ_current_optionsrs   Ú_enable_tracking_callback)rJ   r`  ra  rb  s       rO   r[   zCacheProxyConnection.__init__æ  sˆ   € ô —9‘9“;ˆŒØˆŒ
Ø—Z‘Z×%Ñ%ˆŒ
Ø—J‘J—O‘OˆŒ	Ø—J‘J—O‘OˆŒ	Ø#ˆŒØˆŒÜ$Ÿ>™>Ó+ˆÔØ*.ˆÔ'Ø $ˆÔØ×&Ñ& t×'EÑ'EÕFr4   c                 ó6   — | j                   j                  «       S rX   )rd  rn   rm   s    rO   rn   z CacheProxyConnection.repr_piecesø  s   € Ø�z‰z×%Ñ%Ó'Ð'r4   c                 ó:   — | j                   j                  |«       y rX   )rd  rs   rq   s     rO   rs   z.CacheProxyConnection.register_connect_callbackû  s   € Ø�
‰
×,Ñ,¨XÕ6r4   c                 ó:   — | j                   j                  |«       y rX   )rd  ru   rq   s     rO   ru   z0CacheProxyConnection.deregister_connect_callbackþ  s   € Ø�
‰
×.Ñ.¨xÕ8r4   c                 ó:   — | j                   j                  |«       y rX   )rd  ry   rw   s     rO   ry   zCacheProxyConnection.set_parser  s   € Ø�
‰
×Ñ˜lÕ+r4   c                 ó   — | j                   j                  «        | j                   j                  j                  dd «      }|€&| j                   j                  j                  dd «      }| j                   j                  j                  dd «      }|€&| j                   j                  j                  dd «      }|�|€t	        d«      ‚t        |«      }t        |«      }|| j                  k7  st        || j                  «      dk(  rt	        d«      ‚y )Ns   serverÚservers   versionÚversionz0Cannot retrieve information about server versionr   ziTo maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later)	rd  r{   r›   r	  r$   r.   ÚDEFAULT_SERVER_NAMEr-   ÚMIN_ALLOWED_VERSION)rJ   Úserver_nameÚ
server_vers      rO   r{   zCacheProxyConnection.connect  sô   € Ø�
‰
×ÑÔà—j‘j×3Ñ3×7Ñ7¸	À4ÓHˆØÐØŸ*™*×7Ñ7×;Ñ;¸HÀdÓKˆKØ—Z‘Z×2Ñ2×6Ñ6°zÀ4ÓHˆ
ØÐØŸ™×6Ñ6×:Ñ:¸9ÀdÓKˆJØÐ Ð!3Ü!Ð"TÓUÐUä" :Ó.ˆ
Ü# KÓ0ˆð ˜4×3Ñ3Ò3Ü 
¨D×,DÑ,DÓEÈÒJä!Ø{óð ð Kr4   c                 ó8   — | j                   j                  «        y rX   )rd  r}   rm   s    rO   r}   zCacheProxyConnection.on_connect  s   € Ø�
‰
×ÑÕr4   c                 ó¬   — | j                   5  | j                  j                  «        d d d «        | j                  j                  |Ž  y # 1 sw Y   Œ#xY wrX   )ri  rf  Úflushrd  r€   r   s     rO   r€   zCacheProxyConnection.disconnect  s=   € Ø×ÓØ�K‰K×ÑÔ÷ àˆ�
‰
×Ñ˜tÒ$÷ Ðús   �A
Á
Ac                 ó8   — | j                   j                  «        y rX   )rd  r‚   rm   s    rO   r‚   z!CacheProxyConnection.check_health#  s   € Ø�
‰
×ÑÕ!r4   Tc                 ó:   — | j                   j                  |«       y rX   )rd  r†   r„   s      rO   r†   z(CacheProxyConnection.send_packed_command&  s   € ð 	�
‰
×&Ñ& wÕ/r4   c           	      óˆ  — | j                  «        | j                  5  | j                  j                  t	        |d   d¬«      «      s-d | _         | j                  j                  |i |¤Ž 	 d d d «       y 	 d d d «       |j                  d«      €t        d«      ‚t	        |d   t        |j                  d«      «      ¬«      | _        | j                  5  | j                  j                  | j
                  «      r®| j                  j                  | j
                  «      }|j                  | j                  k7  rf| j                  5  |j                  j                  «       r7|j                  j                  d¬«       |j                  j                  «       rŒ7d d d «       	 d d d «       y | j                  j                  t!        | j
                  | j"                  t$        j&                  | j                  ¬«      «       d d d «        | j                  j                  |i |¤Ž y # 1 sw Y   �Œ¬xY w# 1 sw Y   Œ™xY w# 1 sw Y   Œ?xY w)	Nr   rT   )r…   Ú
redis_keysÚkeyszCannot create cache key.T©r‘   )Ú	cache_keyÚcache_valueÚstatusÚconnection_ref)Ú_process_pending_invalidationsri  rf  Úis_cachabler   rj  rd  rŠ   r	  rÉ   r@   r„  re  rŽ   r”   Úsetr   ÚDUMMY_CACHE_VALUEr   ÚIN_PROGRESS)rJ   r9   r‰   Úentrys       rO   rŠ   z!CacheProxyConnection.send_command+  sË  € Ø×+Ñ+Ô-à×Óð —;‘;×*Ñ*¬8¸DÀ¹GÐPRÔ+SÔTØ26�Ô/Ø'�—
‘
×'Ñ'¨Ð8°Ò8Ø÷ Ðð U÷ ð �:‰:�fÓÐ%ÜÐ7Ó8Ð8ô +3Ø˜‘G¬¨f¯j©j¸Ó.@Ó(Aô+
ˆÔ'ð ×Óð �{‰{�‰˜t×>Ñ>Ô?ØŸ™Ÿ™¨×(GÑ(GÓH�à×'Ñ'¨4¯:©:Ò5ØŸ›Ø#×2Ñ2×;Ñ;Ô=Ø!×0Ñ0×>Ñ>ÈDÐ>ÔQð $×2Ñ2×;Ñ;Õ=÷ )ð ÷ Ðð  �K‰K�O‰OÜØ"×=Ñ=Ø $× 6Ñ 6Ü+×7Ñ7Ø#'§:¡:ô	ô÷! ð6 	 ˆ�
‰
×Ñ Ð0¨Ó0÷W Ñú÷0 )˜ú÷ Ðús9   �AHÃA0H8ÅAH,Æ	H8Æ&AH8ÈH)È,H5	È1H8È8Ic                 ó8   — | j                   j                  |«      S rX   )rd  rŽ   rŒ   s     rO   rŽ   zCacheProxyConnection.can_read[  s   € Ø�z‰z×"Ñ" 7Ó+Ð+r4   Fr�   c                ó�  — | j                   5  | j                  �°| j                  j                  | j                  «      �‹| j                  j                  | j                  «      j                  t
        j                  k7  rKt        j                  | j                  j                  | j                  «      j                  «      cd d d «       S d d d «       | j                  j                  |||¬«      }| j                   5  | j                  €|cd d d «       S |€1| j                  j                  | j                  g«       |cd d d «       S | j                  j                  | j                  «      }|�7t
        j                  |_        ||_	        | j                  j                  |«       d d d «       |S # 1 sw Y   ŒæxY w# 1 sw Y   |S xY w)N)r“   r�   r‘   )ri  rj  rf  r	  rƒ  r   r‰  r¿   rÀ   r‚  rd  r”   Údelete_by_cache_keysÚVALIDr‡  )rJ   r“   r�   r‘   r)  Úcache_entrys         rO   r”   z"CacheProxyConnection.read_response^  sr  € ð ×Óð ×/Ñ/Ð;Ø—K‘K—O‘O D×$CÑ$CÓDÐPØ—K‘K—O‘O D×$CÑ$CÓD×KÑKÜ#×/Ñ/ò0ô —}‘}Ø—K‘K—O‘O D×$CÑ$CÓD×PÑPó÷ ×Ñð —:‘:×+Ñ+Ø-Ø 3Ø%ð ,ó 
ˆð ×Óà×.Ñ.Ð6Ø÷ Ñð
 ÐØ—‘×0Ñ0°$×2QÑ2QÐ1RÔSØ÷ Ñð Ÿ+™+Ÿ/™/¨$×*IÑ*IÓJˆKð Ð&Ü%5×%;Ñ%;�Ô"Ø*2�Ô'Ø—‘—‘ Ô,÷! ð$ ˆ÷I Ðú÷$ ð$ ˆús%   �B3F/Ã<F;Ä)F;ÅAF;Æ/F8Æ;Gc                 ó4   —  | j                   j                  |Ž S rX   )rd  rE   r   s     rO   rE   z!CacheProxyConnection.pack_command‡  s   € Ø&ˆt�z‰z×&Ñ&¨Ð-Ð-r4   c                 ó8   — | j                   j                  |«      S rX   )rd  r™   r—   s     rO   r™   z"CacheProxyConnection.pack_commandsŠ  s   € Ø�z‰z×'Ñ'¨Ó1Ð1r4   ri   c                 ó.   — | j                   j                  S rX   )rd  r›   rm   s    rO   r›   z'CacheProxyConnection.handshake_metadata�  s   € à�z‰z×,Ñ,Ð,r4   c                 ó8   — | j                   j                  «        y rX   )rd  ré   rm   s    rO   ré   zCacheProxyConnection._connect‘  s   € Ø�
‰
×ÑÕr4   c                 ó8   — | j                   j                  «        y rX   )rd  r÷   rm   s    rO   r÷   z CacheProxyConnection._host_error”  s   € Ø�
‰
×ÑÕ r4   Nc                 ó”   — |j                  ddd«       |j                  «        |j                  j                  | j                  «       y )Nr  ÚTRACKINGÚON)rŠ   r”   ræ   Úset_invalidation_push_handlerÚ_on_invalidation_callback)rJ   r`  s     rO   rl  z.CacheProxyConnection._enable_tracking_callback—  s8   € Ø×Ñ˜( J°Ô5Ø×ÑÔØ�‰×2Ñ2°4×3QÑ3QÕRr4   c                 ó€   — | j                  «       r.| j                  j                  d¬«       | j                  «       rŒ-y y )NTr€  )rŽ   rd  r”   rm   s    rO   r…  z3CacheProxyConnection._process_pending_invalidationsœ  s+   € Ø�m‰mŒoØ�J‰J×$Ñ$°$Ð$Ô7ð �m‰m�or4   Údatac                 óÂ   — | j                   5  |d   €| j                  j                  «        n| j                  j                  |d   «       d d d «       y # 1 sw Y   y xY w)Nr   )ri  rf  rz  Údelete_by_redis_keys)rJ   r›  s     rO   r™  z.CacheProxyConnection._on_invalidation_callback   sF   € Ø×Óà�A‰wˆØ—‘×!Ñ!Õ#à—‘×0Ñ0°°a±Ô9÷ ×Ñús   �?AÁArœ   r�   rž   )&rQ   rR   rS   rˆ  ru  rt  rk   r   rg  rh  r[   rn   rs   ru   ry   r{   r}   r€   r‚   r†   rŠ   rŽ   r”   rE   r™   rŸ   r   r   r    r?   r›   ré   r÷   rl  r…  r   r   r™  rT   r4   rO   r^  r^  á  s  „ ØÐØ!ÐØ!ÐðGà!ðGð ðGð —>‘>ó	Gò$(ò7ò9ò,òò. ò%ò
"ó0ò
.1ó`,ð  %ð'Ø=AÐPUô'òR.ò2ð ð- E¨$¨u°e¨|Ñ*<¸dÀ3ÈÀ8¹nÐ*LÑ$Mò -ó ð-òò!ðSÐ.Að SÀdó Sò
8ð:¨d°5¸¸hÀtÈEÁ{Ñ>SÐ9SÑ3TÑ.Uô :r4   r^  c                   óP   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ fd„Zd„ Zˆ xZS )ÚSSLConnectionzåManages SSL connections to and from the Redis server(s).
    This class extends the Connection class, adding SSL functionality, and making
    use of ssl.SSLContext (https://docs.python.org/3/library/ssl.html#ssl.SSLContext)
    c                 óÞ  •— t         st        d«      ‚|| _        || _        |€t        j
                  }nWt        |t        «      rGt        j
                  t        j                  t        j                  dœ}||vrt        d|› �«      ‚||   }|| _
        || _        || _        || _        || _        || _        |	| _        |
| _        || _        || _        || _        || _        t-        ‰| �\  di |¤Ž y)a  Constructor

        Args:
            ssl_keyfile: Path to an ssl private key. Defaults to None.
            ssl_certfile: Path to an ssl certificate. Defaults to None.
            ssl_cert_reqs: The string value for the SSLContext.verify_mode (none, optional, required). Defaults to "required".
            ssl_ca_certs: The path to a file of concatenated CA certificates in PEM format. Defaults to None.
            ssl_ca_data: Either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates.
            ssl_check_hostname: If set, match the hostname during the SSL handshake. Defaults to False.
            ssl_ca_path: The path to a directory containing several CA certificates in PEM format. Defaults to None.
            ssl_password: Password for unlocking an encrypted private key. Defaults to None.

            ssl_validate_ocsp: If set, perform a full ocsp validation (i.e not a stapled verification)
            ssl_validate_ocsp_stapled: If set, perform a validation on a stapled ocsp response
            ssl_ocsp_context: A fully initialized OpenSSL.SSL.Context object to be used in verifying the ssl_ocsp_expected_cert
            ssl_ocsp_expected_cert: A PEM armoured string containing the expected certificate to be returned from the ocsp verification service.
            ssl_min_version: The lowest supported SSL version. It affects the supported SSL versions of the SSLContext. None leaves the default provided by ssl module.
            ssl_ciphers: A string listing the ciphers that are allowed to be used. Defaults to None, which means that the default ciphers are used. See https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_ciphers for more information.

        Raises:
            RedisError
        z$Python wasn't built with SSL supportN)ÚnoneÚoptionalÚrequiredz+Invalid SSL Certificate Requirements Flag: rT   )r,   r&   ÚkeyfileÚcertfileÚsslÚ	CERT_NONEr>   r?   ÚCERT_OPTIONALÚCERT_REQUIREDÚ	cert_reqsÚca_certsÚca_dataÚca_pathÚcheck_hostnameÚcertificate_passwordÚssl_validate_ocspÚssl_validate_ocsp_stapledÚssl_ocsp_contextÚssl_ocsp_expected_certÚssl_min_versionÚssl_ciphersrD  r[   )rJ   Ússl_keyfileÚssl_certfileÚssl_cert_reqsÚssl_ca_certsÚssl_ca_dataÚssl_check_hostnameÚssl_ca_pathÚssl_passwordr°  r±  r²  r³  r´  rµ  r‰   Ú	CERT_REQSrÔ   s                    €rO   r[   zSSLConnection.__init__¯  sõ   ø€ õP ÜÐCÓDÐDà"ˆŒØ$ˆŒØÐ ÜŸM™M‰MÜ˜¤sÔ+äŸ™Ü×-Ñ-Ü×-Ñ-ñˆIð
  IÑ-Ü ØAÀ-ÀÐQóð ð & mÑ4ˆMØ&ˆŒØ$ˆŒØ"ˆŒØ"ˆŒØ0ˆÔØ$0ˆÔ!Ø!2ˆÔØ)BˆÔ&Ø 0ˆÔØ&<ˆÔ#Ø.ˆÔØ&ˆÔÜ‰ÑÑ"˜6Ó"r4   c                 óŒ   •— t         ‰| �  «       }	 | j                  |«      S # t        t        f$ r |j                  «        ‚ w xY w)zN
        Wrap the socket with SSL support, handling potential errors.
        )rD  ré   Ú_wrap_socket_with_sslrð   r&   r  )rJ   rò   rÔ   s     €rO   ré   zSSLConnection._connect÷  sH   ø€ ô ‰wÑÓ!ˆð	Ø×-Ñ-¨dÓ3Ð3øÜœÐ$ò 	Ø�J‰JŒLØð	ús	   ‘" ¢!Ac                 ó,  — t        j                  «       }| j                  |_        | j                  |_        | j
                  s| j                  r2|j                  | j
                  | j                  | j                  ¬«       | j                  €| j                  €| j                  �2|j                  | j                  | j                  | j                  ¬«       | j                  �| j                  |_        | j                  r|j!                  | j                  «       | j"                  du rt$        du rt'        d«      ‚| j(                  r| j"                  rt'        d«      ‚|j+                  || j,                  ¬«      }| j(                  �r+d	dl}d
dlm} | j4                  €f|j6                  j9                  |j6                  j:                  «      }|j=                  | j
                  «       |j?                  | j                  «       n| j4                  }|jA                  || jB                  «       |j6                  jE                  |tG        jF                  «       «      }|jI                  «        |jK                  | j,                  | jL                  f«       |jO                  «        |jQ                  «        |S | j"                  du rRt$        rLd
dlm)}  ||| j,                  | jL                  | j                  «      }	|	jU                  «       r|S tW        d«      ‚|S )z­
        Wraps the socket with SSL support.

        Args:
            sock: The plain socket to wrap with SSL.

        Returns:
            An SSL wrapped socket.
        )r¥  r¤  r¦   N)ÚcafileÚcapathÚcadataTFzcryptography is not installed.zKEither an OCSP staple or pure OCSP connection must be validated - not both.)Úserver_hostnamer   r   )Úocsp_staple_verifier)ÚOCSPVerifierzocsp validation error),r¦  Úcreate_default_contextr®  rª  Úverify_moder¥  r¤  Úload_cert_chainr¯  r«  r­  r¬  Úload_verify_locationsr´  Úminimum_versionrµ  Úset_ciphersr°  r*   r&   r±  Úwrap_socketr?  ÚOpenSSLÚocsprÆ  r²  ÚSSLÚContextÚSSLv23_METHODÚuse_certificate_fileÚuse_privatekey_fileÚset_ocsp_client_callbackr³  r<  rï   Úrequest_ocspr{   r@  Údo_handshaker  rÇ  Úis_validr$   )
rJ   rò   ÚcontextÚsslsockrÏ  rÆ  Ú
staple_ctxÚconrÇ  Úos
             rO   rÀ  z#SSLConnection._wrap_socket_with_ssl  su  € ô ×,Ñ,Ó.ˆØ!%×!4Ñ!4ˆÔØ"Ÿn™nˆÔØ�=Š=˜DŸLšLØ×#Ñ#ØŸ™ØŸ™Ø×2Ñ2ð $ô ð �M‰MÐ%Ø�|‰|Ð'Ø�|‰|Ð'à×)Ñ)Ø—}‘}¨T¯\©\À$Ç,Á,ð *ô ð ×ÑÐ+Ø&*×&:Ñ&:ˆGÔ#Ø×ÒØ×Ñ × 0Ñ 0Ô1Ø×!Ñ! TÑ)Ô.DÈÑ.MÜÐ=Ó>Ð>à×)Ò)¨d×.DÒ.DÜðóð ð
 ×%Ñ% d¸D¿I¹IÐ%ÓFˆð ×)Ó)Ûå2ð ×$Ñ$Ð,Ø$Ÿ[™[×0Ñ0°·±×1JÑ1JÓK�
Ø×/Ñ/°·±Ô>Ø×.Ñ.¨t¯|©|Õ<à!×2Ñ2�
à×/Ñ/Ø$ d×&AÑ&Aôð
 —+‘+×(Ñ(¨´V·]±]³_ÓEˆCØ×ÑÔØ�K‰K˜Ÿ™ D§I¡IÐ.Ô/Ø×ÑÔØ�L‰LŒNØˆNð ×!Ñ! TÑ)Õ.DÝ*á˜W d§i¡i°·±¸D¿M¹MÓJˆAØ�z‰zŒ|Ø�ä%Ð&=Ó>Ð>Øˆr4   )NNr£  NNFNNFFNNNN)rQ   rR   rS   r7  r[   ré   rÀ  r[  r\  s   @rO   rŸ  rŸ  ©  sF   ø„ ñð ØØ ØØØ ØØØØ"'ØØ#ØØõF#ôP	öMr4   rŸ  c                   ó6   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zd„ Zˆ xZS )ÚUnixDomainSocketConnectionz4Manages UDS communication to and from a Redis serverc                 ó@   •— t        ‰| �  di |¤Ž || _        || _        y r>  )rD  r[   Úpathr§   )rJ   râ  r§   r‰   rÔ   s       €rO   r[   z#UnixDomainSocketConnection.__init__U  s"   ø€ Ü‰ÑÑ"˜6Ò"ØˆŒ	Ø,ˆÕr4   c                 ó�   — d| j                   fd| j                  fg}| j                  r|j                  d| j                  f«       |S )Nrâ  r¥   r¯   )râ  r¥   r¯   rC   rF  s     rO   rn   z&UnixDomainSocketConnection.repr_piecesZ  sB   € Ø˜4Ÿ9™9Ð%¨¨d¯g©g Ð7ˆØ×ÒØ�M‰M˜=¨$×*:Ñ*:Ð;Ô<Øˆr4   c                 óJ  — t        j                   t         j                  t         j                  «      }|j                  | j                  «       	 |j                  | j                  «       |j                  | j                  «       |S # t        $ r |j                  «        ‚ w xY w)z&Create a Unix domain socket connection)
rï   ÚAF_UNIXrI  rP  r¨   r{   râ  rð   r  r§   )rJ   rò   s     rO   ré   z#UnixDomainSocketConnection._connect`  sy   € ä�}‰}œVŸ^™^¬V×-?Ñ-?Ó@ˆØ�‰˜×3Ñ3Ô4ð	Ø�L‰L˜Ÿ™Ô#ð
 	�‰˜×+Ñ+Ô,Øˆøô ò 	à�J‰JŒLØð	ús   ÁB ÂB"c                 ó   — | j                   S rX   )râ  rm   s    rO   r÷   z&UnixDomainSocketConnection._host_errorm  s   € Ø�y‰yÐr4   )Ú NrZ  r\  s   @rO   rà  rà  R  s   ø„ Ù:õ-ò
òör4   rà  )Ú0ÚFÚFALSEÚNÚNOc                 óv   — | �| dk(  ry t        | t        «      r| j                  «       t        v ryt	        | «      S )Nrç  F)r>   r?   ÚupperÚFALSE_STRINGSr9  )rM   s    rO   Úto_boolrð  t  s4   € Ø€}˜ šØÜ�%œÔ %§+¡+£-´=Ñ"@ØÜ�‹;Ðr4   )
r¥   r§   r¨   rA  r©   r¾   Úmax_connectionsr®   r»  r�   c                 óB  — | j                  d«      s-| j                  d«      s| j                  d«      st        d«      ‚t        | «      } i }t        | j                  «      j                  «       D ]N  \  }}|sŒ	t        |«      dkD  sŒt        |d   «      }t        j                  |«      }|r	  ||«      ||<   ŒJ|||<   ŒP | j                  rt        | j                  «      |d<   | j                  rt        | j                  «      |d	<   | j                  d
k(  r/| j                  rt        | j                  «      |d<   t        |d<   |S | j                   rt        | j                   «      |d<   | j"                  rt%        | j"                  «      |d<   | j                  r6d|vr2	 t%        t        | j                  «      j'                  dd«      «      |d<   | j                  dk(  r	t*        |d<   |S # t        t        f$ r t        d|› d�«      ‚w xY w# t(        t        f$ r Y ŒMw xY w)Nzredis://z	rediss://zunix://zRRedis URL must specify one of the following schemes (redis://, rediss://, unix://)r   zInvalid value for 'z' in connection URL.r²   r¦   Úunixrâ  Úconnection_classr?  r@  r¥   Ú/rç  Úrediss)Ú
startswithrÉ   r   r   ÚqueryrO  r`   r   ÚURL_QUERY_ARGUMENT_PARSERSr	  rF   r²   r¦   Úschemerâ  rà  Úhostnamer@  rÇ   ÚreplaceÚAttributeErrorrŸ  )Úurlr‰   ÚnamerM   r
  s        rO   Ú	parse_urlr   Š  sô  € à�‰�zÔ"Ø�>‰>˜+Ô&Ø�>‰>˜)Ô$äð5ó
ð 	
ô
 �3‹-€CØ€Fä §	¡	Ó*×0Ñ0Ö2‰ˆˆeÚ”S˜“Z !“^Ü˜E !™HÓ%ˆEÜ/×3Ñ3°DÓ9ˆFÙðWÙ#)¨%£=�F˜4’Lð  %��t’ð 3ð ‡|‚|Ü$ S§\¡\Ó2ˆˆzÑØ
‡|‚|Ü$ S§\¡\Ó2ˆˆzÑð ‡z�z�VÒØ�8Š8Ü$ S§X¡XÓ.ˆF�6‰NÜ%?ˆÐ!Ñ"ð& €Mð! �<Š<Ü$ S§\¡\Ó2ˆF�6‰NØ�8Š8Ü  §¡›]ˆF�6‰Nð �8Š8˜ FÑ*ðÜ"¤7¨3¯8©8Ó#4×#<Ñ#<¸SÀ"Ó#EÓF��t‘ð �:‰:˜Ò!Ü)6ˆFÐ%Ñ&à€MøôC "¤:Ð.ò WÜ$Ð':¸4¸&Ð@TÐ%UÓVÐVðWûô6 #¤JÐ/ò Ùðús   Â-G*Æ1H Ç*H	ÈHÈHc                   óÈ   — e Zd ZdZed„ «       Zeddfdee   dee	   fd„Z
deeffd„Zd	„ Zdd
„Zdd„Zdeddfd„Zdefd„Zdd„Zdd„Zdddefd„Zddeddfd„Zdd„Zdd„Zy)ÚConnectionPoola¬  
    Create a connection pool. ``If max_connections`` is set, then this
    object raises :py:class:`~redis.exceptions.ConnectionError` when the pool's
    limit is reached.

    By default, TCP connections are created unless ``connection_class``
    is specified. Use class:`.UnixDomainSocketConnection` for
    unix sockets.

    Any additional keyword arguments are passed to the constructor of
    ``connection_class``.
    c                 ób   — t        |«      }d|v r|d   |d<   |j                  |«        | di |¤ŽS )a  
        Return a connection pool configured from the given URL.

        For example::

            redis://[[username]:[password]]@localhost:6379/0
            rediss://[[username]:[password]]@localhost:6379/0
            unix://[username@]/path/to/socket.sock?db=0[&password=password]

        Three URL schemes are supported:

        - `redis://` creates a TCP socket connection. See more at:
          <https://www.iana.org/assignments/uri-schemes/prov/redis>
        - `rediss://` creates a SSL wrapped TCP socket connection. See more at:
          <https://www.iana.org/assignments/uri-schemes/prov/rediss>
        - ``unix://``: creates a Unix Domain Socket connection.

        The username, password, hostname, path and all querystring values
        are passed through urllib.parse.unquote in order to replace any
        percent-encoded values with their corresponding characters.

        There are several ways to specify a database number. The first value
        found will be used:

            1. A ``db`` querystring option, e.g. redis://localhost?db=0
            2. If using the redis:// or rediss:// schemes, the path argument
               of the url, e.g. redis://localhost/0
            3. A ``db`` keyword argument to this function.

        If none of these options are specified, the default db=0 is used.

        All querystring options are cast to their appropriate Python types.
        Boolean arguments can be specified with string values "True"/"False"
        or "Yes"/"No". Values that cannot be properly cast cause a
        ``ValueError`` to be raised. Once parsed, the querystring arguments
        and keyword arguments are passed to the ``ConnectionPool``'s
        class initializer. In the case of conflicting arguments, querystring
        arguments always win.
        rô  rT   )r   Úupdate)Úclsrþ  r‰   Úurl_optionss       rO   Úfrom_urlzConnectionPool.from_urlÑ  s?   € ôR   “nˆà Ñ'Ø.4Ð5GÑ.HˆKÐ*Ñ+à�‰�kÔ"Ù‰}�V‰}Ðr4   Nrñ  Úcache_factoryc                 óö  — |xs d}t        |t        «      r|dk  rt        d«      ‚|| _        || _        || _        d | _        || _        |j                  d«      s|j                  d«      rÁ|j                  d«      dvrt        d«      ‚| j                  j                  d«      }|�#t        |t        «      st        d	«      ‚|| _        nc| j                  � | j                  j                  «       | _        n7t        | j                  j                  d«      «      j                  «       | _        |j                  dd «       |j                  dd «       t        j                  «       | _        | j#                  «        y )
Nl        r   z,"max_connections" must be a positive integerÚcache_configra  r¶   )r¹   r(  z4Client caching is only supported with RESP version 3z#Cache must implement CacheInterface)r>   rÇ   rÉ   rô  Úconnection_kwargsrñ  ra  Ú_cache_factoryr	  r&   r   Ú	get_cacher   Úpoprg  rh  Ú
_fork_lockÚreset)rJ   rô  rñ  r  r  ra  s         rO   r[   zConnectionPool.__init__  sM  € ð *Ò2¨UˆÜ˜/¬3Ô/°?ÀQÒ3FÜÐKÓLÐLà 0ˆÔØ!2ˆÔØ.ˆÔØˆŒ
Ø+ˆÔà× Ñ  Ô0Ð4E×4IÑ4IÈ'Ô4RØ ×$Ñ$ ZÓ0¸Ñ@Ü Ð!WÓXÐXà×*Ñ*×.Ñ.¨wÓ7ˆEàÐ Ü! %¬Ô8Ü$Ð%JÓKÐKà"�•
à×&Ñ&Ð2Ø!%×!4Ñ!4×!>Ñ!>Ó!@�D•Jä!-Ø×.Ñ.×2Ñ2°>ÓBó"ç‘i“kð ”Jð 	×Ñ˜g tÔ,Ø×Ñ˜n¨dÔ3ô $Ÿ.™.Ó*ˆŒØ�
‰
�r4   ri   c                 ó¬   — dt        | «      j                  › dt        | «      j                  › dt         | j                  di | j
                  ¤Ž«      › d�S )NrÐ   rÑ   rÒ   rÓ   rT   )ÚtyperR   rQ   Úreprrô  r  rm   s    rO   rØ   zConnectionPool.__repr__4  sV   € à”�T“
×%Ñ%Ð& a¬¨T«
×(;Ñ(;Ð'<Ø”Ð*�T×*Ñ*ÑD¨T×-CÑ-CÑDÓEÐFÀbðJð	
r4   c                 ó:   — | j                   j                  dd«      S )zª
        Returns:
            The RESP protocol version, or ``None`` if the protocol is not specified,
            in which case the server default will be used.
        r¶   N)r  r	  rm   s    rO   r2  zConnectionPool.get_protocol:  s   € ð ×%Ñ%×)Ñ)¨*°dÓ;Ð;r4   c                 ó¢   — t        j                  «       | _        d| _        g | _        t        «       | _        t        j                  «       | _	        y )Nr   )
rg  rh  Ú_lockÚ_created_connectionsÚ_available_connectionsr‡  Ú_in_use_connectionsrº   r»   r¼   rm   s    rO   r  zConnectionPool.resetB  s9   € Ü—^‘^Ó%ˆŒ
Ø$%ˆÔ!Ø&(ˆÔ#Ü#&£5ˆÔ ô —9‘9“;ˆ�r4   c                 óf  — | j                   t        j                  «       k7  rq| j                  j	                  d¬«      }|st
        ‚	 | j                   t        j                  «       k7  r| j                  «        | j                  j                  «        y y # | j                  j                  «        w xY w)Né   )r�   )r¼   rº   r»   r  Úacquirer#   r  Úrelease)rJ   Úacquireds     rO   Ú	_checkpidzConnectionPool._checkpidS  s€   € ðF �8‰8”r—y‘y“{Ò"Ø—‘×.Ñ.°qÐ.Ó9ˆHÙÜ*Ð*ð*Ø—8‘8œrŸy™y›{Ò*Ø—J‘J”Là—‘×'Ñ'Õ)ð #øð —‘×'Ñ'Õ)ús   Á1B ÂB0Úcommand_namer<  c                 ód  — | j                  «        | j                  5  	 | j                  j                  «       }| j                  j                  |«       ddd«       	 j                  «        	 |j                  «       r| j                  €t        d«      ‚|S # t        $ r | j                  «       }Y Œyw xY w# 1 sw Y   ŒcxY w# t        t        f$ r? |j                  «        |j                  «        |j                  «       rt        d«      ‚Y |S w xY w# t        $ r | j                  «       ‚ w xY w)zGet a connection from the poolNúConnection has dataúConnection not ready)r  r  r  r  Ú
IndexErrorÚmake_connectionr  Úaddr{   rŽ   ra  r$   rð   r€   r  r  ©rJ   r   r  ÚoptionsÚ
connections        rO   Úget_connectionzConnectionPool.get_connection‚  s#  € à�‰ÔØ�Z‹Zð4Ø!×8Ñ8×<Ñ<Ó>�
ð ×$Ñ$×(Ñ(¨Ô4÷ ð	à×ÑÔ ð
BØ×&Ñ&Ô(¨T¯Z©ZÐ-?Ü)Ð*?Ó@Ð@ð Ðøô3 ò 4Ø!×1Ñ1Ó3’
ð4ú÷ ˆZûô" $¤WÐ-ò BØ×%Ñ%Ô'Ø×"Ñ"Ô$Ø×&Ñ&Ô(Ü)Ð*@ÓAÐAð )ð ÐðBûô
 ò 	ð �L‰L˜Ô$Øð		úsX   �B6ŸB¹B6ÁD Á.'C ÂB3Â0B6Â2B3Â3B6Â6B?ÃA
DÄD ÄDÄD ÄD/c                 ó–   — | j                   }t        |j                  dd«      |j                  dd«      |j                  dd«      ¬«      S )z,Return an encoder based on encoding settingsrª   r£   r«   r¤   r¬   F)rª   r«   r¬   )r  r   r	  )rJ   r‰   s     rO   Úget_encoderzConnectionPool.get_encoder£  sF   € à×'Ñ'ˆÜØ—Z‘Z 
¨GÓ4Ø"ŸJ™JÐ'8¸(ÓCØ#ŸZ™ZÐ(:¸EÓBô
ð 	
r4   c                 ó:  — | j                   | j                  k\  rt        d«      ‚| xj                   dz  c_         | j                  �;t	         | j
                  di | j                  ¤Ž| j                  | j                  «      S  | j
                  di | j                  ¤ŽS )zCreate a new connectionzToo many connectionsr   rT   )r  rñ  r$   ra  r^  rô  r  r  rm   s    rO   r%  zConnectionPool.make_connection¬  s�   € à×$Ñ$¨×(<Ñ(<Ò<Ü!Ð"8Ó9Ð9Ø×!Ò! QÑ&Õ!à�:‰:Ð!Ü'Ø%�×%Ñ%Ñ?¨×(>Ñ(>Ñ?ÀÇÁÈTÏZÉZóð ð %ˆt×$Ñ$Ñ> t×'=Ñ'=Ñ>Ð>r4   r)  c                 óv  — | j                  «        | j                  5  	 | j                  j                  |«       | j                  |«      r| j                  j                  |«       n/| xj                  dz  c_        |j                  «        	 ddd«       y	 ddd«       y# t        $ r Y Œqw xY w# 1 sw Y   yxY w)z(Releases the connection back to the poolr   N)
r  r  r  rä   ÚKeyErrorÚowns_connectionr  rC   r  r€   ©rJ   r)  s     rO   r  zConnectionPool.release¹  s£   € à�‰ÔØ�Z‹ZðØ×(Ñ(×/Ñ/°
Ô;ð ×#Ñ# JÔ/Ø×+Ñ+×2Ñ2°:Õ>ð
 ×)Ò)¨QÑ.Õ)Ø×%Ñ%Ô'Ø÷! ˆZð ?÷ ˆZøô ò ñ ðú÷ ˆZús.   �B/ŸB ºAB/Â 	B,Â)B/Â+B,Â,B/Â/B8c                 ó4   — |j                   | j                   k(  S rX   )r¼   r1  s     rO   r0  zConnectionPool.owns_connectionÎ  s   € Ø�~‰~ §¡Ñ)Ð)r4   Úinuse_connectionsc                 óô   — | j                  «        | j                  5  |r!t        | j                  | j                  «      }n| j                  }|D ]  }|j                  «        Œ 	 ddd«       y# 1 sw Y   yxY w)zÿ
        Disconnects connections in the pool

        If ``inuse_connections`` is True, disconnect connections that are
        current in use, potentially by other threads. Otherwise only disconnect
        connections that are idle in the pool.
        N)r  r  r   r  r  r€   )rJ   r3  Úconnectionsr)  s       rO   r€   zConnectionPool.disconnectÑ  s`   € ð 	�‰ÔØ�Z‹ZÙ Ü#Ø×/Ñ/°×1IÑ1Ió‘ð #×9Ñ9�ã)�
Ø×%Ñ%Õ'ñ *÷ �Z‰Zús   �AA.Á.A7c                 ó$   — | j                  «        y)z-Close the pool, disconnecting all connectionsNrì   rm   s    rO   r  zConnectionPool.closeå  r  r4   c                 óž   — | j                   j                  d|i«       | j                  D ]	  }||_        Œ | j                  D ]	  }||_        Œ y )Nr³   )r  r  r  r³   r  )rJ   r³   r`  s      rO   Ú	set_retryzConnectionPool.set_retryé  sI   € Ø×Ñ×%Ñ% w°Ð&6Ô7Ø×/Ô/ˆDØˆD�Jð 0à×,Ô,ˆDØˆD�Jñ -r4   rh   )ri   rk   )r)  r<  ri   Nrœ   )r³   r)   ri   N)rQ   rR   rS   r7  Úclassmethodr  r<  r   rÇ   r   r[   r?   rØ   r2  r  r  r*  r   r,  r%  r  r0  r9  r€   r  r8  rT   r4   rO   r  r  Ã  sÅ   „ ñð ñ.ó ð.ðd $Ø)-Ø9=ñ	0ð " #™ð0ð  Ð 5Ñ6ó	0ðd
˜3 ˜*ó 
ò<óó"-*ð^¨3ð À\ó ðB
˜Wó 
ó?óð**¨,ð *¸3ó *ñ(¨Dð (¸Dó (ó(ôr4   r  c                   óJ   ‡ — e Zd ZdZddeefˆ fd„	Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zˆ xZS )
ÚBlockingConnectionPoola  
    Thread-safe blocking connection pool::

        >>> from redis.client import Redis
        >>> client = Redis(connection_pool=BlockingConnectionPool())

    It performs the same function as the default
    :py:class:`~redis.ConnectionPool` implementation, in that,
    it maintains a pool of reusable connections that can be shared by
    multiple redis clients (safely across threads if required).

    The difference is that, in the event that a client tries to get a
    connection from the pool when all of connections are in use, rather than
    raising a :py:class:`~redis.ConnectionError` (as the default
    :py:class:`~redis.ConnectionPool` implementation does), it
    makes the client wait ("blocks") for a specified number of seconds until
    a connection becomes available.

    Use ``max_connections`` to increase / decrease the pool size::

        >>> pool = BlockingConnectionPool(max_connections=10)

    Use ``timeout`` to tell it either how many seconds to wait for a connection
    to become available, or to block forever:

        >>> # Block forever.
        >>> pool = BlockingConnectionPool(timeout=None)

        >>> # Raise a ``ConnectionError`` after five seconds if a connection is
        >>> # not available.
        >>> pool = BlockingConnectionPool(timeout=5)
    é2   é   c                 óF   •— || _         || _        t        ‰| �  d||dœ|¤Ž y )N)rô  rñ  rT   )Úqueue_classr�   rD  r[   )rJ   rñ  r�   rô  r?  r  rÔ   s         €rO   r[   zBlockingConnectionPool.__init__  s6   ø€ ð 'ˆÔØˆŒÜ‰Ñð 	
Ø-Ø+ñ	
ð  ó	
r4   c                 óÞ   — | j                  | j                  «      | _        	 	 | j                  j                  d «       Œ# t        $ r Y nw xY wg | _        t        j                  «       | _        y rX   )	r?  rñ  ÚpoolÚ
put_nowaitr   Ú_connectionsrº   r»   r¼   rm   s    rO   r  zBlockingConnectionPool.reset#  sf   € à×$Ñ$ T×%9Ñ%9Ó:ˆŒ	ØðØ—	‘	×$Ñ$ TÔ*ð øô ò Ùðúð
 ˆÔô —9‘9“;ˆ�s   £? ¿	AÁ
Ac                 ó  — | j                   �<t         | j                  di | j                  ¤Ž| j                   | j                  «      }n | j                  di | j                  ¤Ž}| j
                  j                  |«       |S )zMake a fresh connection.rT   )ra  r^  rô  r  r  rC  rC   r1  s     rO   r%  z&BlockingConnectionPool.make_connection;  sr   € à�:‰:Ð!Ü-Ø%�×%Ñ%Ñ?¨×(>Ñ(>Ñ?ÀÇÁÈTÏZÉZó‰Jð /˜×.Ñ.ÑH°×1GÑ1GÑHˆJØ×Ñ× Ñ  Ô,ØÐr4   c                 ó
  — | j                  «        d}	 | j                  j                  d| j                  ¬«      }|€| j                  «       }	 |j                  «        	 |j                  «       rt        d«      ‚	 |S # t        $ r t        d«      ‚w xY w# t
        t        f$ r? |j                  «        |j                  «        |j                  «       rt        d«      ‚Y |S w xY w# t        $ r | j                  |«       ‚ w xY w)a7  
        Get a connection, blocking for ``self.timeout`` until a connection
        is available from the pool.

        If the connection returned is ``None`` then creates a new connection.
        Because we use a last-in first-out queue, the existing connections
        (having been returned to the pool after the initial ``None`` values
        were added) will be returned before ``None`` values. This means we only
        create new connections when we need to, i.e.: the actual number of
        connections will only increase in response to demand.
        NT)Úblockr�   zNo connection available.r"  r#  )r  rA  r	  r�   r   r$   r%  r{   rŽ   rð   r€   r  r  r'  s        rO   r*  z%BlockingConnectionPool.get_connectionF  s  € ð 	�‰Ôð ˆ
ð	>ØŸ™Ÿ™¨T¸4¿<¹<˜ÓHˆJð ÐØ×-Ñ-Ó/ˆJð	à×ÑÔ ð
BØ×&Ñ&Ô(Ü)Ð*?Ó@Ð@ð )ð Ðøô= ò 	>ô "Ð"<Ó=Ð=ð	>ûô( $¤WÐ-ò BØ×%Ñ%Ô'Ø×"Ñ"Ô$Ø×&Ñ&Ô(Ü)Ð*@ÓAÐAð )ð ÐðBûô
 ò 	à�L‰L˜Ô$Øð	ús6   ”'A= ÁC& ÁB Á=BÂA
C#ÃC& Ã"C#Ã#C& Ã&Dc                 óô   — | j                  «        | j                  |«      s,|j                  «        | j                  j	                  d«       y	 | j                  j	                  |«       y# t
        $ r Y yw xY w)z)Releases the connection back to the pool.N)r  r0  r€   rA  rB  r   r1  s     rO   r  zBlockingConnectionPool.releasez  sj   € ð 	�‰ÔØ×#Ñ# JÔ/ð
 ×!Ñ!Ô#Ø�I‰I× Ñ  Ô&Øð	Ø�I‰I× Ñ  Õ,øÜò 	ñ ð	ús   ÁA+ Á+	A7Á6A7c                 óf   — | j                  «        | j                  D ]  }|j                  «        Œ y)z(Disconnects all connections in the pool.N)r  rC  r€   r1  s     rO   r€   z!BlockingConnectionPool.disconnect�  s(   € à�‰ÔØ×+Ô+ˆJØ×!Ñ!Õ#ñ ,r4   )rQ   rR   rS   r7  r<  r   r[   r  r%  r*  r  r€   r[  r\  s   @rO   r;  r;  ñ  s6   ø„ ñðF ØØ#Øõ
ò ò0	ò2òhö*$r4   r;  )\r¿   rº   rï   r¦  rG   rg  rà   Úabcr   Ú	itertoolsr   Úqueuer   r   r   r   Útypingr	   r
   r   r   r   r   r   Úurllib.parser   r   r   Úredis.cacher   r   r   r   r   r   Ú_parsersr   r   r   r   Úbackoffr   Úcredentialsr   r    Ú
exceptionsr!   r"   r#   r$   r%   r&   r'   r(   r³   r)   Úutilsr*   r+   r,   r-   r.   r/   r0   r1   rD   r_   rd   ra   r]   rÈ   Úobjectr½   Ú__annotations__r6   r8   rV   rk   r¢   r<  r^  rŸ  rà  rï  rð  rÇ   r8  Úlistrù  r   r  r;  rT   r4   rO   Ú<module>rW     s„  ðÜ Û 	Û Û 
Û 
Û Û Ý Ý ß (Ñ (Ý ß C× CÑ Cß 4Ñ 4÷÷ ÷ JÓ IÝ ß O÷	÷ 	ó 	õ ÷	÷ 	ó 	ñ Ûà€Ø€
Ø€Ø€	àÐ á‹8€à�E˜,¨°nÐDÑEÑFÓ FÙØ"�Mà €M÷ñ ÷$0ñ 0÷fBñ BôJJ)Ð,ô J)ôZC*Ð#ô C*ôLE:Ð.ô E:ôPf�Jô fôRÐ!3ô ð> /€òð ØØ#ØØØØØ Ø!ØñÐ ò6÷rkñ kô\	b$˜^õ b$r4   