ó
    Ö›‘hc\  ã                   óÖ   • S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  Sr " S	 S
\5      r " S S\5      r " S S\5      r " S S5      r " S S\\
5      r/ SQrg)ap  
Memcache client protocol. Memcached is a caching server, storing data in the
form of pairs key/value, and memcache is the protocol to talk with it.

To connect to a server, create a factory for L{MemCacheProtocol}::

    from twisted.internet import reactor, protocol
    from twisted.protocols.memcache import MemCacheProtocol, DEFAULT_PORT
    d = protocol.ClientCreator(reactor, MemCacheProtocol
        ).connectTCP("localhost", DEFAULT_PORT)
    def doSomething(proto):
        # Here you call the memcache operations
        return proto.set("mykey", "a lot of data")
    d.addCallback(doSomething)
    reactor.run()

All the operations of the memcache protocol are present, but
L{MemCacheProtocol.set} and L{MemCacheProtocol.get} are the more important.

See U{http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt} for
more information about the protocol.
é    )Údeque)ÚDeferredÚTimeoutErrorÚfail)ÚLineReceiver)ÚTimeoutMixin)Úlog)ÚnativeStringÚnetworkStringiË+  c                   ó   • \ rS rSrSrSrg)ÚNoSuchCommandé(   z9
Exception raised when a non existent command is called.
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú^C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/protocols/memcache.pyr   r   (   ó   † ôr   r   c                   ó   • \ rS rSrSrSrg)ÚClientErroré.   z)
Error caused by an invalid client call.
r   Nr   r   r   r   r   r   .   r   r   r   c                   ó   • \ rS rSrSrSrg)ÚServerErroré4   z"
Problem happening on the server.
r   Nr   r   r   r   r   r   4   r   r   r   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚCommandé:   a  
Wrap a client action into an object, that holds the values used in the
protocol.

@ivar _deferred: the L{Deferred} object that will be fired when the result
    arrives.
@type _deferred: L{Deferred}

@ivar command: name of the command sent to the server.
@type command: L{bytes}
c                 óx   • Xl         [        5       U l        UR                  5        H  u  p4[	        XU5        M     g)z¯
Create a command.

@param command: the name of the command.
@type command: L{bytes}

@param kwargs: this values will be stored as attributes of the object
    for future use
N)Úcommandr   Ú	_deferredÚitemsÚsetattr)Úselfr$   ÚkwargsÚkÚvs        r   Ú__init__ÚCommand.__init__G   s.   € ð ŒÜ!›ˆŒØ—L‘L–N‰DˆAÜ�D˜QÖò #r   c                 ó:   • U R                   R                  U5        g)z2
Shortcut method to fire the underlying deferred.
N)r%   Úcallback)r(   Úvalues     r   ÚsuccessÚCommand.successV   s   € ð 	�‰×Ñ Õ&r   c                 ó:   • U R                   R                  U5        g)z%
Make the underlying deferred fails.
N)r%   Úerrback)r(   Úerrors     r   r   ÚCommand.fail\   s   € ð 	�‰×Ñ˜uÕ%r   )r%   r$   N)	r   r   r   r   r   r,   r1   r   r   r   r   r   r!   r!   :   s   † ñ
ò ò'õ&r   r!   c                   ó&  • \ rS rSrSrSrSrS,S jrS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS-S jrS-S jrS rS.S jrS.S jrS.S jr S.S jr!S  r"S! r#S" r$S/S# jr%S/S$ jr&S% r'S0S' jr(S( r)S) r*S* r+S+r,g&)1ÚMemCacheProtocoléc   aí  
MemCache protocol: connect to a memcached server to store/retrieve values.

@ivar persistentTimeOut: the timeout period used to wait for a response.
@type persistentTimeOut: L{int}

@ivar _current: current list of requests waiting for an answer from the
    server.
@type _current: L{deque} of L{Command}

@ivar _lenExpected: amount of data expected in raw mode, when reading for
    a value.
@type _lenExpected: L{int}

@ivar _getBuffer: current buffer of data, used to store temporary data
    when reading in raw mode.
@type _getBuffer: L{list}

@ivar _bufferLength: the total amount of bytes in C{_getBuffer}.
@type _bufferLength: L{int}

@ivar _disconnected: indicate if the connectionLost has been called or not.
@type _disconnected: L{bool}
éú   Fc                 óh   • [        5       U l        SU l        SU l        SU l        U=U l        U l        g)z«
Create the protocol.

@param timeOut: the timeout to wait before detecting that the
    connection is dead and close it. It's expressed in seconds.
@type timeOut: L{int}
N)r   Ú_currentÚ_lenExpectedÚ
_getBufferÚ_bufferLengthÚpersistentTimeOutÚtimeOut)r(   rA   s     r   r,   ÚMemCacheProtocol.__init__€   s3   € ô ›ˆŒØ ˆÔØˆŒØ!ˆÔØ07Ð7ˆÔ ¥r   c                 ó¤   • U R                   (       a?  U R                   R                  5       nUR                  U5        U R                   (       a  M>  gg)zG
Cancel all the outstanding commands, making them fail with C{reason}.
N)r<   Úpopleftr   )r(   ÚreasonÚcmds      r   Ú_cancelCommandsÚ MemCacheProtocol._cancelCommandsŽ   s4   € ð �m�mØ—-‘-×'Ñ'Ó)ˆCØ�H‰H�VÔð �m�m‹mr   c                 ól   • U R                  [        S5      5        U R                  R                  5         g)z*
Close the connection in case of timeout.
zConnection timeoutN)rG   r   Ú	transportÚloseConnection©r(   s    r   ÚtimeoutConnectionÚ"MemCacheProtocol.timeoutConnection–   s(   € ð 	×Ñœ\Ð*>Ó?Ô@Ø�‰×%Ñ%Õ'r   c                 ó`   • SU l         U R                  U5        [        R                  " X5        g)z)
Cause any outstanding commands to fail.
TN)Ú_disconnectedrG   r   ÚconnectionLost)r(   rE   s     r   rQ   ÚMemCacheProtocol.connectionLost�   s(   € ð "ˆÔØ×Ñ˜VÔ$Ü×#Ò# DÕ1r   c                 óˆ   • U R                   (       d  U R                  U R                  5        [        R                  " X5        g)z1
Override sendLine to add a timeout to response.
N)r<   Ú
setTimeoutr@   r   ÚsendLine)r(   Úlines     r   rU   ÚMemCacheProtocol.sendLine¥   s+   € ð �}�}Ø�O‰O˜D×2Ñ2Ô3Ü×Ò˜dÕ)r   c                 óR  • U R                  5         U R                  R                  U5        U =R                  [	        U5      -  sl        U R                  U R
                  S-   :¼  aÁ  SR                  U R                  5      nUSU R
                   nXR
                  S-   S nUnSU l        SU l        SU l        U R                  S   nUR                  (       a7  UR                  UR                     u  pgXgU4UR                  UR                  '   OXEl        U R                  U5        gg)z
Collect data for a get.
é   r   Nr   )ÚresetTimeoutr>   Úappendr?   Úlenr=   Újoinr<   ÚmultipleÚvaluesÚ
currentKeyr0   ÚsetLineMode)r(   ÚdataÚbufÚremÚvalrF   ÚflagsÚcass           r   ÚrawDataReceivedÚ MemCacheProtocol.rawDataReceived­   sÿ   € ð 	×ÑÔØ�‰×Ñ˜tÔ$Ø×Òœc $›iÑ'ÕØ×Ñ ×!2Ñ!2°QÑ!6Ó6Ø—8‘8˜DŸO™OÓ,ˆDØÐ*˜×*Ñ*Ð+ˆCØ×(Ñ(¨1Ñ,Ð.Ð/ˆCØˆCØ $ˆDÔØ"ˆDŒOØ!%ˆDÔØ—-‘- Ñ"ˆCØ�|�|Ø ŸZ™Z¨¯©Ñ7‘
�Ø.3¸#Ð->�—
‘
˜3Ÿ>™>Ò*à”	Ø×Ñ˜SÕ!ð 7r   c                 óV   • U R                   R                  5       R                  S5        g)z/
Manage a success response to a set operation.
TN©r<   rD   r1   rL   s    r   Ú
cmd_STOREDÚMemCacheProtocol.cmd_STOREDÄ   ó   € ð 	�‰×ÑÓ×'Ñ'¨Õ-r   c                 óV   • U R                   R                  5       R                  S5        g)zr
Manage a specific 'not stored' response to a set operation: this is not
an error, but some condition wasn't met.
FNrk   rL   s    r   Úcmd_NOT_STOREDÚMemCacheProtocol.cmd_NOT_STOREDÊ   s   € ð
 	�‰×ÑÓ×'Ñ'¨Õ.r   c           	      óò  • U R                   R                  5       nUR                  S:X  a  UR                  (       aF  UR                  R                  5        VVs0 s H  u  p#X#SSS2   _M     nnnUR                  U5        gUR                  UR                  UR                  45        gUR                  S:X  a`  UR                  (       a  UR                  UR                  5        gUR                  UR                  UR                  UR                  45        gUR                  S:X  a  UR                  UR                  5        g[        SR                  [        UR                  5      5      5      es  snnf )z2
This the end token to a get or a stat operation.
ó   getNrY   ó   getsó   statsz%Unexpected END response to {} command)r<   rD   r$   r^   r_   r&   r1   rf   r0   rg   ÚRuntimeErrorÚformatr
   )r(   rF   Úkeyre   r_   s        r   Úcmd_ENDÚMemCacheProtocol.cmd_ENDÑ   s  € ð �m‰m×#Ñ#Ó%ˆØ�;‰;˜&Ó Ø�|�|Ø8;¿
¹
×8HÑ8HÔ8JÔKÒ8J©H¨C˜#¡3 Q 3™xš-Ñ8J�ÑKØ—‘˜FÕ#à—‘˜SŸY™Y¨¯	©	Ð2Õ3Ø�[‰[˜GÓ#Ø�|�|Ø—‘˜CŸJ™JÕ'à—‘˜SŸY™Y¨¯©°·±Ð;Õ<Ø�[‰[˜HÓ$Ø�K‰K˜Ÿ
™
Õ#äØ7×>Ñ>Ü  §¡Ó-óóð ùó Ls   ÁE3c                 óV   • U R                   R                  5       R                  S5        g)z-
Manage error response for incr/decr/delete.
FNrk   rL   s    r   Úcmd_NOT_FOUNDÚMemCacheProtocol.cmd_NOT_FOUNDê   ó   € ð 	�‰×ÑÓ×'Ñ'¨Õ.r   c                 óê  • U R                   S   nUR                  S:X  a  UR                  5       u  p4nSnOUR                  5       u  p4pV[        U5      U l        / U l        SU l        UR                  (       a;  X2R                  ;  a  [        S5      eX2l
        [        U5      U/UR                  U'   O1UR                  U:w  a  [        S5      e[        U5      Ul        Xbl        U R                  5         g)z*
Prepare the reading a value after a get.
r   rs   r   zUnexpected commands answer.N)r<   r$   ÚsplitÚintr=   r>   r?   r^   Úkeysrv   r`   r_   rx   rf   rg   Ú
setRawMode)r(   rV   rF   rx   rf   Úlengthrg   s          r   Ú	cmd_VALUEÚMemCacheProtocol.cmd_VALUEð   sÇ   € ð �m‰m˜AÑˆØ�;‰;˜&Ó Ø!%§¡£ÑˆC˜Ø‰Cà&*§j¡j£lÑ#ˆC˜Ü ›KˆÔØˆŒØˆÔØ�<�<ØŸ(™(Ó"Ü"Ð#@ÓAÐAØ ŒNÜ" 5›z¨3Ð/ˆC�J‰J�sŠOà�w‰w˜#‹~Ü"Ð#@ÓAÐAÜ˜E›
ˆCŒIØŒGØ�‰Õr   c                 óf   • U R                   S   nUR                  SS5      u  p4XBR                  U'   g)z
Reception of one stat line.
r   ó    é   N)r<   r€   r_   )r(   rV   rF   rx   re   s        r   Úcmd_STATÚMemCacheProtocol.cmd_STAT	  s/   € ð �m‰m˜AÑˆØ—:‘:˜d AÓ&‰ˆØ�
‰
�3Šr   c                 óV   • U R                   R                  5       R                  U5        g)z
Read version token.
Nrk   )r(   ÚversionDatas     r   Úcmd_VERSIONÚMemCacheProtocol.cmd_VERSION  s   € ð 	�‰×ÑÓ×'Ñ'¨Õ4r   c                 ó–   • [         R                  " S5        U R                  R                  5       nUR	                  [        5       5        g)z'
A non-existent command has been sent.
zNon-existent command sent.N)r	   Úerrr<   rD   r   r   )r(   rF   s     r   Ú	cmd_ERRORÚMemCacheProtocol.cmd_ERROR  s1   € ô 	�ŠÐ,Ô-Ø�m‰m×#Ñ#Ó%ˆØ�‰”“Õ!r   c                 ó´   • [        U5      n[        R                  " SU-   5        U R                  R	                  5       nUR                  [        U5      5        g)z 
An invalid input as been sent.
zInvalid input: N)Úreprr	   r‘   r<   rD   r   r   ©r(   ÚerrTextrF   s      r   Úcmd_CLIENT_ERRORÚ!MemCacheProtocol.cmd_CLIENT_ERROR  sB   € ô �w“-ˆÜ�ŠÐ! GÑ+Ô,Ø�m‰m×#Ñ#Ó%ˆØ�‰”˜WÓ%Õ&r   c                 ó´   • [        U5      n[        R                  " SU-   5        U R                  R	                  5       nUR                  [        U5      5        g)z$
An error has happened server-side.
zServer error: N)r•   r	   r‘   r<   rD   r   r   r–   s      r   Úcmd_SERVER_ERRORÚ!MemCacheProtocol.cmd_SERVER_ERROR(  sB   € ô �w“-ˆÜ�ŠÐ  7Ñ*Ô+Ø�m‰m×#Ñ#Ó%ˆØ�‰”˜WÓ%Õ&r   c                 óV   • U R                   R                  5       R                  S5        g)z.
A delete command has completed successfully.
TNrk   rL   s    r   Úcmd_DELETEDÚMemCacheProtocol.cmd_DELETED1  rn   r   c                 óV   • U R                   R                  5       R                  S5        g)z&
The last command has been completed.
TNrk   rL   s    r   Úcmd_OKÚMemCacheProtocol.cmd_OK7  rn   r   c                 óV   • U R                   R                  5       R                  S5        g)z%
A C{checkAndSet} update has failed.
FNrk   rL   s    r   Ú
cmd_EXISTSÚMemCacheProtocol.cmd_EXISTS=  r~   r   c                 ó  • U R                  5         UR                  SS5      S   n[        U S[        U5      -   S5      nUb0  UR                  SS5      SS nU(       a  U" US   5        OtU" 5         OlUR	                  SS5      n[        U S[        U5      -   S5      nUb  U" 5         O6U R
                  R                  5       n[        U5      nUR                  U5        U R
                  (       d  U R                  S5        gg)z(
Receive line commands from the server.
rˆ   r‰   r   Úcmd_Nó   _)
rZ   r€   Úgetattrr
   Úreplacer<   rD   r�   r1   rT   )r(   rV   ÚtokenrF   Úargsre   s         r   ÚlineReceivedÚMemCacheProtocol.lineReceivedC  sá   € ð 	×ÑÔØ—
‘
˜4 Ó# AÑ&ˆä�d˜F¤\°%Ó%8Ñ8¸$Ó?ˆØ‰?Ø—:‘:˜d AÓ& q rÐ*ˆDÞÙ�D˜‘G•á•ð —<‘<  dÓ+ˆDÜ˜$ ¬°dÓ);Ñ ;¸TÓBˆCØ‰Ù•ð —m‘m×+Ñ+Ó-�Ü˜$“i�Ø—‘˜CÔ Ø�}�}à�O‰O˜DÕ!ð r   c                 ó&   • U R                  SX5      $ )an  
Increment the value of C{key} by given value (default to 1).
C{key} must be consistent with an int. Return the new value.

@param key: the key to modify.
@type key: L{bytes}

@param val: the value to increment.
@type val: L{int}

@return: a deferred with will be called back with the new value
    associated with the key (after the increment).
@rtype: L{Deferred}
s   incr©Ú	_incrdecr©r(   rx   re   s      r   Ú	incrementÚMemCacheProtocol.increment`  s   € ð �~‰~˜g sÓ0Ð0r   c                 ó&   • U R                  SX5      $ )aˆ  
Decrement the value of C{key} by given value (default to 1).
C{key} must be consistent with an int. Return the new value, coerced to
0 if negative.

@param key: the key to modify.
@type key: L{bytes}

@param val: the value to decrement.
@type val: L{int}

@return: a deferred with will be called back with the new value
    associated with the key (after the decrement).
@rtype: L{Deferred}
s   decrr°   r²   s      r   Ú	decrementÚMemCacheProtocol.decrementq  s   € ð  �~‰~˜g sÓ0Ð0r   c                 óÔ  • U R                   (       a  [        [        S5      5      $ [        U[        5      (       d!  [        [        S[        U5       S35      5      $ [        U5      U R                  :”  a  [        [        S5      5      $ SR                  XS[        U5      4-  /5      nU R                  U5        [        XS9nU R                  R                  U5        UR                  $ )z!
Internal wrapper for incr/decr.
únot connectedúInvalid type for key: ú, expecting bytesúKey too longrˆ   s   %d©rx   )rP   r   rv   Ú
isinstanceÚbytesr   Útyper\   ÚMAX_KEY_LENGTHr]   r�   rU   r!   r<   r[   r%   )r(   rF   rx   re   ÚfullcmdÚcmdObjs         r   r±   ÚMemCacheProtocol._incrdecrƒ  sÄ   € ð ××Üœ _Ó5Ó6Ð6Ü˜#œu×%Ñ%ÜÜÐ4´T¸#³Y°KÐ?PÐQÓRóð ô ˆs‹8�d×)Ñ)Ó)Üœ NÓ3Ó4Ð4Ø—)‘)˜S u´°C³¨{Ñ':Ð;Ó<ˆØ�‰�gÔÜ˜Ñ&ˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   c                 ó*   • U R                  SXX4S5      $ )a-  
Replace the given C{key}. It must already exist in the server.

@param key: the key to replace.
@type key: L{bytes}

@param val: the new value associated with the key.
@type val: L{bytes}

@param flags: the flags to store with the key.
@type flags: L{int}

@param expireTime: if different from 0, the relative time in seconds
    when the key will be deleted from the store.
@type expireTime: L{int}

@return: a deferred that will fire with C{True} if the operation has
    succeeded, and C{False} with the key didn't previously exist.
@rtype: L{Deferred}
s   replacer   ©Ú_set©r(   rx   re   rf   Ú
expireTimes        r   rª   ÚMemCacheProtocol.replace•  s   € ð* �y‰y˜ S¨uÀ#ÓFÐFr   c                 ó*   • U R                  SXX4S5      $ )a  
Add the given C{key}. It must not exist in the server.

@param key: the key to add.
@type key: L{bytes}

@param val: the value associated with the key.
@type val: L{bytes}

@param flags: the flags to store with the key.
@type flags: L{int}

@param expireTime: if different from 0, the relative time in seconds
    when the key will be deleted from the store.
@type expireTime: L{int}

@return: a deferred that will fire with C{True} if the operation has
    succeeded, and C{False} with the key already exists.
@rtype: L{Deferred}
s   addr   rÆ   rÈ   s        r   ÚaddÚMemCacheProtocol.add¬  ó   € ð* �y‰y˜ ¨5¸cÓBÐBr   c                 ó*   • U R                  SXX4S5      $ )aÉ  
Set the given C{key}.

@param key: the key to set.
@type key: L{bytes}

@param val: the value associated with the key.
@type val: L{bytes}

@param flags: the flags to store with the key.
@type flags: L{int}

@param expireTime: if different from 0, the relative time in seconds
    when the key will be deleted from the store.
@type expireTime: L{int}

@return: a deferred that will fire with C{True} if the operation has
    succeeded.
@rtype: L{Deferred}
s   setr   rÆ   rÈ   s        r   ÚsetÚMemCacheProtocol.setÃ  rÎ   r   c                 ó*   • U R                  SXXEU5      $ )aÝ  
Change the content of C{key} only if the C{cas} value matches the
current one associated with the key. Use this to store a value which
hasn't been modified since last time you fetched it.

@param key: The key to set.
@type key: L{bytes}

@param val: The value associated with the key.
@type val: L{bytes}

@param cas: Unique 64-bit value returned by previous call of C{get}.
@type cas: L{bytes}

@param flags: The flags to store with the key.
@type flags: L{int}

@param expireTime: If different from 0, the relative time in seconds
    when the key will be deleted from the store.
@type expireTime: L{int}

@return: A deferred that will fire with C{True} if the operation has
    succeeded, C{False} otherwise.
@rtype: L{Deferred}
s   casrÆ   )r(   rx   re   rg   rf   rÉ   s         r   ÚcheckAndSetÚMemCacheProtocol.checkAndSetÚ  s   € ð4 �y‰y˜ ¨5¸cÓBÐBr   c           
      óš  • U R                   (       a  [        [        S5      5      $ [        U[        5      (       d!  [        [        S[        U5       S35      5      $ [        U5      U R                  :”  a  [        [        S5      5      $ [        U[        5      (       d!  [        [        S[        U5       S35      5      $ U(       a  SU-   n[        U5      nSR                  X[        SXEU4-  5      /5      U-   nU R                  U5        U R                  U5        [        XXGS9n	U R                  R                  U	5        U	R                  $ )	z&
Internal wrapper for setting values.
r¹   rº   r»   r¼   zInvalid type for value: rˆ   z%d %d %d)rx   rf   r„   )rP   r   rv   r¾   r¿   r   rÀ   r\   rÁ   r]   r   rU   r!   r<   r[   r%   )
r(   rF   rx   re   rf   rÉ   rg   r„   rÂ   rÃ   s
             r   rÇ   ÚMemCacheProtocol._setö  s0  € ð ××Üœ _Ó5Ó6Ð6Ü˜#œu×%Ñ%ÜÜÐ4´T¸#³Y°KÐ?PÐQÓRóð ô ˆs‹8�d×)Ñ)Ó)Üœ NÓ3Ó4Ð4Ü˜#œu×%Ñ%ÜÜÐ6´t¸C³y°kÐARÐSÓTóð ö Ø˜‘*ˆCÜ�S“ˆà�I‰IØœ=¨°uÈ&Ð6QÑ)QÓRÐSóð ñð 	ð 	�‰�gÔØ�‰�cÔÜ˜¨UÑBˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   c                 ó,   • U R                  SXSSS5      $ )aL  
Append given data to the value of an existing key.

@param key: The key to modify.
@type key: L{bytes}

@param val: The value to append to the current value associated with
    the key.
@type val: L{bytes}

@return: A deferred that will fire with C{True} if the operation has
    succeeded, C{False} otherwise.
@rtype: L{Deferred}
s   appendr   r   rÆ   r²   s      r   r[   ÚMemCacheProtocol.append  s   € ð  �y‰y˜ C¨a°°CÓ8Ð8r   c                 ó,   • U R                  SXSSS5      $ )aN  
Prepend given data to the value of an existing key.

@param key: The key to modify.
@type key: L{bytes}

@param val: The value to prepend to the current value associated with
    the key.
@type val: L{bytes}

@return: A deferred that will fire with C{True} if the operation has
    succeeded, C{False} otherwise.
@rtype: L{Deferred}
s   prependr   r   rÆ   r²   s      r   ÚprependÚMemCacheProtocol.prepend'  s   € ð  �y‰y˜ S¨q°!°SÓ9Ð9r   c                 ó*   • U R                  U/US5      $ )a6  
Get the given C{key}. It doesn't support multiple keys. If
C{withIdentifier} is set to C{True}, the command issued is a C{gets},
that will return the current identifier associated with the value. This
identifier has to be used when issuing C{checkAndSet} update later,
using the corresponding method.

@param key: The key to retrieve.
@type key: L{bytes}

@param withIdentifier: If set to C{True}, retrieve the current
    identifier along with the value and the flags.
@type withIdentifier: L{bool}

@return: A deferred that will fire with the tuple (flags, value) if
    C{withIdentifier} is C{False}, or (flags, cas identifier, value)
    if C{True}.  If the server indicates there is no value
    associated with C{key}, the returned value will be L{None} and
    the returned flags will be C{0}.
@rtype: L{Deferred}
F©Ú_get)r(   rx   ÚwithIdentifiers      r   ÚgetÚMemCacheProtocol.get9  s   € ð, �y‰y˜#˜ °Ó6Ð6r   c                 ó&   • U R                  XS5      $ )at  
Get the given list of C{keys}.  If C{withIdentifier} is set to C{True},
the command issued is a C{gets}, that will return the identifiers
associated with each values. This identifier has to be used when
issuing C{checkAndSet} update later, using the corresponding method.

@param keys: The keys to retrieve.
@type keys: L{list} of L{bytes}

@param withIdentifier: If set to C{True}, retrieve the identifiers
    along with the values and the flags.
@type withIdentifier: L{bool}

@return: A deferred that will fire with a dictionary with the elements
    of C{keys} as keys and the tuples (flags, value) as values if
    C{withIdentifier} is C{False}, or (flags, cas identifier, value) if
    C{True}.  If the server indicates there is no value associated with
    C{key}, the returned values will be L{None} and the returned flags
    will be C{0}.
@rtype: L{Deferred}

@since: 9.0
TrÝ   )r(   r‚   rß   s      r   ÚgetMultipleÚMemCacheProtocol.getMultipleQ  s   € ð0 �y‰y˜¨tÓ4Ð4r   c           	      óh  • [        U5      nU R                  (       a  [        [        S5      5      $ U Hj  n[	        U[
        5      (       d#  [        [        S[        U5       S35      5      s  $ [        U5      U R                  :”  d  MV  [        [        S5      5      s  $    U(       a  SnOSnSR                  U/U-   5      nU R                  U5        U(       a  U Vs0 s H  oDS_M     nn[        XQUS	S
9nO[        XQS   SSSSS9nU R                  R                  U5        UR                  $ s  snf )z.
Helper method for C{get} and C{getMultiple}.
r¹   rº   r»   r¼   rt   rs   rˆ   )r   r   NT)r‚   r_   r^   r   Nr   F)rx   r0   rf   rg   r^   )ÚlistrP   r   rv   r¾   r¿   r   rÀ   r\   rÁ   r]   rU   r!   r<   r[   r%   )	r(   r‚   rß   r^   rx   rF   rÂ   r_   rÃ   s	            r   rÞ   ÚMemCacheProtocol._getk  s  € ô �D‹zˆØ××Üœ _Ó5Ó6Ð6ÛˆCÜ˜c¤5×)Ñ)ÜÜÐ"8¼¸c»¸ÐCTÐ UÓVóò ô �3‹x˜$×-Ñ-Õ-ÜœK¨Ó7Ó8Ò8ñ ö Ø‰CàˆCØ—)‘)˜S˜E D™LÓ)ˆØ�‰�gÔÞÙ59Ó:²T¨c˜>Ò)±TˆFÐ:Ü˜S°FÀTÑJ‰FäØ˜a™¨°A¸3ÈñˆFð 	�‰×Ñ˜VÔ$Ø×ÑÐùò ;s   ÃD/Nc                 óî   • U(       a  SU-   nOSnU R                   (       a  [        [        S5      5      $ U R                  U5        [	        S0 S9nU R
                  R                  U5        UR                  $ )a�  
Get some stats from the server. It will be available as a dict.

@param arg: An optional additional string which will be sent along
    with the I{stats} command.  The interpretation of this value by
    the server is left undefined by the memcache protocol
    specification.
@type arg: L{None} or L{bytes}

@return: a deferred that will fire with a L{dict} of the available
    statistics.
@rtype: L{Deferred}
s   stats ru   r¹   )r_   ©rP   r   rv   rU   r!   r<   r[   r%   )r(   ÚargrF   rÃ   s       r   ÚstatsÚMemCacheProtocol.stats‰  sd   € ö Ø˜c‘/‰CàˆCØ××Üœ _Ó5Ó6Ð6Ø�‰�cÔÜ˜¨"Ñ-ˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   c                 óÒ   • U R                   (       a  [        [        S5      5      $ U R                  S5        [	        S5      nU R
                  R                  U5        UR                  $ )z‚
Get the version of the server.

@return: a deferred that will fire with the string value of the
    version.
@rtype: L{Deferred}
r¹   s   versionré   ©r(   rÃ   s     r   ÚversionÚMemCacheProtocol.version¢  sQ   € ð ××Üœ _Ó5Ó6Ð6Ø�‰�jÔ!Ü˜Ó$ˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   c                 óB  • U R                   (       a  [        [        S5      5      $ [        U[        5      (       d!  [        [        S[        U5       S35      5      $ U R                  SU-   5        [        SUS9nU R                  R                  U5        UR                  $ )zÜ
Delete an existing C{key}.

@param key: the key to delete.
@type key: L{bytes}

@return: a deferred that will be called back with C{True} if the key
    was successfully deleted, or C{False} if not.
@rtype: L{Deferred}
r¹   rº   r»   s   delete s   deleter½   )rP   r   rv   r¾   r¿   r   rÀ   rU   r!   r<   r[   r%   )r(   rx   rÃ   s      r   ÚdeleteÚMemCacheProtocol.delete±  s‹   € ð ××Üœ _Ó5Ó6Ð6Ü˜#œu×%Ñ%ÜÜÐ4´T¸#³Y°KÐ?PÐQÓRóð ð 	�‰�j 3Ñ&Ô'Ü˜¨Ñ,ˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   c                 óÒ   • U R                   (       a  [        [        S5      5      $ U R                  S5        [	        S5      nU R
                  R                  U5        UR                  $ )z�
Flush all cached values.

@return: a deferred that will be called back with C{True} when the
    operation has succeeded.
@rtype: L{Deferred}
r¹   s	   flush_allré   rî   s     r   ÚflushAllÚMemCacheProtocol.flushAllÇ  sQ   € ð ××Üœ _Ó5Ó6Ð6Ø�‰�lÔ#Ü˜Ó&ˆØ�‰×Ñ˜VÔ$Ø×ÑÐr   )r?   r<   rP   r>   r=   r@   rA   )é<   )r‰   )r   r   )F)N)-r   r   r   r   r   rÁ   rP   r,   rG   rM   rQ   rU   rh   rl   rp   ry   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   r8   r8   c   sÐ   † ñð2 €NØ€Mô8òò(ò2ò*ò"ò..ò/òò2/òò2ò5ò"ò'ò'ò.ò.ò/ò"ô:1ô"1ò$ ô$Gô.Cô.Cô.Cò8 ò>9ò$:ô$7ô05ò4 ô< ò2 ò õ, r   r8   )r8   ÚDEFAULT_PORTr   r   r   N)r   Úcollectionsr   Útwisted.internet.deferr   r   r   Útwisted.protocols.basicr   Útwisted.protocols.policiesr   Útwisted.pythonr	   Útwisted.python.compatr
   r   rø   Ú	Exceptionr   r   r   r!   r8   Ú__all__r   r   r   Ú<module>r     sm   ðñ
õ0 ç ?Ñ ?Ý 0Ý 3Ý ß =à€ô�Iô ô�)ô ô�)ô ÷&&ñ &&ôRq	 �| \ô q	 òh�r   