ó
[³XMc           @   s   d  Z  y d d l m Z Wn' e k
 rC d e f d „  ƒ  YZ n Xd d l m Z d d l m Z d d l	 m
 Z
 m Z m Z d d l m Z d	 Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d d d
 d d g Z d S(   sp  
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.
iÿÿÿÿ(   t   dequeR    c           B   s   e  Z d  „  Z RS(   c         C   s   |  j  d ƒ S(   Ni    (   t   pop(   t   self(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   popleft    s    (   t   __name__t
   __module__R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR       s   (   t   LineReceiver(   t   TimeoutMixin(   t   Deferredt   failt   TimeoutError(   t   logiË+  t   NoSuchCommandc           B   s   e  Z d  Z RS(   sA   
    Exception raised when a non existent command is called.
    (   R   R   t   __doc__(    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   /   s   t   ClientErrorc           B   s   e  Z d  Z RS(   s1   
    Error caused by an invalid client call.
    (   R   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   6   s   t   ServerErrorc           B   s   e  Z d  Z RS(   s*   
    Problem happening on the server.
    (   R   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   =   s   t   Commandc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s6  
    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: C{str}
    c         K   sF   | |  _  t ƒ  |  _ x* | j ƒ  D] \ } } t |  | | ƒ q" Wd S(   sÝ   
        Create a command.

        @param command: the name of the command.
        @type command: C{str}

        @param kwargs: this values will be stored as attributes of the object
            for future use
        N(   t   commandR   t	   _deferredt   itemst   setattr(   R   R   t   kwargst   kt   v(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   __init__Q   s    
	c         C   s   |  j  j | ƒ d S(   sB   
        Shortcut method to fire the underlying deferred.
        N(   R   t   callback(   R   t   value(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   successa   s    c         C   s   |  j  j | ƒ d S(   s5   
        Make the underlying deferred fails.
        N(   R   t   errback(   R   t   error(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR	   h   s    (   R   R   R   R   R   R	   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   D   s   		t   MemCacheProtocolc           B   s‘  e  Z d  Z d Z e Z d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z d „  Z d d d „ Z d d d „ Z d d d „ Z d d d „ Z  d  „  Z! d! „  Z" d" „  Z# e d# „ Z$ e d$ „ Z% d% „  Z& d* d& „ Z( d' „  Z) d( „  Z* d) „  Z+ RS(+   s1  
    MemCache protocol: connect to a memcached server to store/retrieve values.

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

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

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

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

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

    @ivar _disconnected: indicate if the connectionLost has been called or not.
    @type _disconnected: C{bool}
    iú   i<   c         C   s;   t  ƒ  |  _ d |  _ d |  _ d |  _ | |  _ |  _ d S(   sÓ   
        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: C{int}
        N(   R    t   _currentt   Nonet   _lenExpectedt
   _getBuffert   _bufferLengtht   persistentTimeOutt   timeOut(   R   R%   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   Œ   s
    			c         C   s0   x) |  j  r+ |  j  j ƒ  } | j | ƒ q Wd S(   sW   
        Cancel all the outstanding commands, making them fail with C{reason}.
        N(   R   R   R	   (   R   t   reasont   cmd(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   _cancelCommands›   s    c         C   s$   |  j  t d ƒ ƒ |  j j ƒ  d S(   s:   
        Close the connection in case of timeout.
        s   Connection timeoutN(   R(   R
   t	   transportt   loseConnection(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   timeoutConnection¤   s    c         C   s*   t  |  _ |  j | ƒ t j |  | ƒ d S(   s9   
        Cause any outstanding commands to fail.
        N(   t   Truet   _disconnectedR(   R   t   connectionLost(   R   R&   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR.   ¬   s    	c         C   s0   |  j  s |  j |  j ƒ n  t j |  | ƒ d S(   sA   
        Override sendLine to add a timeout to response.
        N(   R   t
   setTimeoutR$   R   t   sendLine(   R   t   line(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR0   µ   s    	c         C   sû   |  j  ƒ  |  j j | ƒ |  j t | ƒ 7_ |  j |  j d k r÷ d j |  j ƒ } | |  j  } | |  j d } | } d |  _ d |  _ d |  _ |  j d } | j	 rÞ | j
 | j \ } } | | | f | j
 | j <n	 | | _ |  j | ƒ n  d S(   s)   
        Collect data for a get.
        i   t    i    N(   t   resetTimeoutR"   t   appendR#   t   lenR!   t   joinR    R   t   multiplet   valuest
   currentKeyR   t   setLineMode(   R   t   datat   buft   remt   valR'   t   flagst   cas(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   rawDataReceived¾   s"    
					c         C   s   |  j  j ƒ  j t ƒ d S(   s?   
        Manage a success response to a set operation.
        N(   R   R   R   R,   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt
   cmd_STOREDÖ   s    c         C   s   |  j  j ƒ  j t ƒ d S(   sŠ   
        Manage a specific 'not stored' response to a set operation: this is not
        an error, but some condition wasn't met.
        N(   R   R   R   t   False(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_NOT_STOREDÝ   s    c         C   s  |  j  j ƒ  } | j d k r” | j rx t g  | j j ƒ  D]% \ } } | | d d d … f ^ q: ƒ } | j | ƒ q| j | j | j	 f ƒ no | j d k rá | j r¿ | j | j ƒ q| j | j | j
 | j	 f ƒ n" | j d k r| j | j ƒ n  d S(   sB   
        This the end token to a get or a stat operation.
        t   getNi   t   getst   stats(   R   R   R   R7   t   dictR8   t	   iteritemsR   R?   R   R@   (   R   R'   t   keyR>   R8   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_ENDå   s    	;	"c         C   s   |  j  j ƒ  j t ƒ d S(   s=   
        Manage error response for incr/decr/delete.
        N(   R   R   R   RC   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_NOT_FOUNDú   s    c         C   s  |  j  d } | j d k r: | j ƒ  \ } } } d } n | j ƒ  \ } } } } t | ƒ |  _ g  |  _ d |  _ | j r¿ | | j k rš t	 d ƒ ‚ n  | | _
 t | ƒ | g | j | <n6 | j | k rÝ t	 d ƒ ‚ n  t | ƒ | _ | | _ |  j ƒ  d S(   s:   
        Prepare the reading a value after a get.
        i    RE   R2   s   Unexpected commands answer.N(   R   R   t   splitt   intR!   R"   R#   R7   t   keyst   RuntimeErrorR9   R8   RJ   R?   R@   t
   setRawMode(   R   R1   R'   RJ   R?   t   lengthR@   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt	   cmd_VALUE  s$    						c         C   s6   |  j  d } | j d d ƒ \ } } | | j | <d S(   s-   
        Reception of one stat line.
        i    t    i   N(   R   RM   R8   (   R   R1   R'   RJ   R>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_STAT  s    c         C   s   |  j  j ƒ  j | ƒ d S(   s%   
        Read version token.
        N(   R   R   R   (   R   t   versionData(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_VERSION$  s    c         C   s0   t  j d ƒ |  j j ƒ  } | j t ƒ  ƒ d S(   s8   
        An non-existent command has been sent.
        s   Non-existent command sent.N(   R   t   errR   R   R	   R   (   R   R'   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt	   cmd_ERROR+  s    c         C   s:   t  j d | f ƒ |  j j ƒ  } | j t | ƒ ƒ d S(   s0   
        An invalid input as been sent.
        s   Invalid input: %sN(   R   RX   R   R   R	   R   (   R   t   errTextR'   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_CLIENT_ERROR4  s    c         C   s:   t  j d | f ƒ |  j j ƒ  } | j t | ƒ ƒ d S(   s4   
        An error has happened server-side.
        s   Server error: %sN(   R   RX   R   R   R	   R   (   R   RZ   R'   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_SERVER_ERROR=  s    c         C   s   |  j  j ƒ  j t ƒ d S(   s>   
        A delete command has completed successfully.
        N(   R   R   R   R,   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_DELETEDF  s    c         C   s   |  j  j ƒ  j t ƒ d S(   s6   
        The last command has been completed.
        N(   R   R   R   R,   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   cmd_OKM  s    c         C   s   |  j  j ƒ  j t ƒ d S(   s5   
        A C{checkAndSet} update has failed.
        N(   R   R   R   RC   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt
   cmd_EXISTST  s    c         C   s  |  j  ƒ  | j d d ƒ d } t |  d | f d ƒ } | d k	 r| | j d d ƒ d } | rr | | d ƒ qå | ƒ  ni | j d d ƒ } t |  d | f d ƒ } | d k	 r½ | ƒ  n( |  j j ƒ  } t | ƒ } | j | ƒ |  j sþ |  j	 d ƒ n  d S(   s8   
        Receive line commands from the server.
        RT   i   i    s   cmd_%st   _N(
   R3   RM   t   getattrR    t   replaceR   R   RN   R   R/   (   R   R1   t   tokenR'   t   argsR>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   lineReceived[  s"    


	i   c         C   s   |  j  d | | ƒ S(   s¼  
        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: C{str}

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

        @return: a deferred with will be called back with the new value
            associated with the key (after the increment).
        @rtype: L{Deferred}
        t   incr(   t	   _incrdecr(   R   RJ   R>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt	   incrementy  s    c         C   s   |  j  d | | ƒ S(   sÞ  
        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: C{str}

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

        @return: a deferred with will be called back with the new value
            associated with the key (after the decrement).
        @rtype: L{Deferred}
        t   decr(   Rg   (   R   RJ   R>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt	   decrement‹  s    c         C   s¹   |  j  r t t d ƒ ƒ St | t ƒ sE t t d t | ƒ f ƒ ƒ St | ƒ |  j k rj t t d ƒ ƒ Sd | | t	 | ƒ f } |  j
 | ƒ t | d | ƒ} |  j j | ƒ | j S(   s1   
        Internal wrapper for incr/decr.
        s   not connecteds,   Invalid type for key: %s, expecting a strings   Key too longs   %s %s %dRJ   (   R-   R	   RP   t
   isinstancet   strR   t   typeR5   t   MAX_KEY_LENGTHRN   R0   R   R   R4   R   (   R   R'   RJ   R>   t   fullcmdt   cmdObj(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRg   ž  s    	i    c         C   s   |  j  d | | | | d ƒ S(   s™  
        Replace the given C{key}. It must already exist in the server.

        @param key: the key to replace.
        @type key: C{str}

        @param val: the new value associated with the key.
        @type val: C{str}

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

        @param expireTime: if different from 0, the relative time in seconds
            when the key will be deleted from the store.
        @type expireTime: C{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}
        Rb   R2   (   t   _set(   R   RJ   R>   R?   t
   expireTime(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRb   °  s    c         C   s   |  j  d | | | | d ƒ S(   s€  
        Add the given C{key}. It must not exist in the server.

        @param key: the key to add.
        @type key: C{str}

        @param val: the value associated with the key.
        @type val: C{str}

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

        @param expireTime: if different from 0, the relative time in seconds
            when the key will be deleted from the store.
        @type expireTime: C{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}
        t   addR2   (   Rq   (   R   RJ   R>   R?   Rr   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRs   È  s    c         C   s   |  j  d | | | | d ƒ S(   s5  
        Set the given C{key}.

        @param key: the key to set.
        @type key: C{str}

        @param val: the value associated with the key.
        @type val: C{str}

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

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

        @return: a deferred that will fire with C{True} if the operation has
            succeeded.
        @rtype: L{Deferred}
        t   setR2   (   Rq   (   R   RJ   R>   R?   Rr   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRt   à  s    c         C   s   |  j  d | | | | | ƒ S(   sg  
        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: C{str}

        @param val: The value associated with the key.
        @type val: C{str}

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

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

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

        @return: A deferred that will fire with C{True} if the operation has
            succeeded, C{False} otherwise.
        @rtype: L{Deferred}
        R@   (   Rq   (   R   RJ   R>   R@   R?   Rr   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   checkAndSetø  s    c   
      C   s   |  j  r t t d ƒ ƒ St | t ƒ sE t t d t | ƒ f ƒ ƒ St | ƒ |  j k rj t t d ƒ ƒ St | t ƒ s– t t d t | ƒ f ƒ ƒ S| r© d | } n  t | ƒ } d | | | | | | f } |  j	 | ƒ |  j	 | ƒ t
 | d | d | d	 | ƒ}	 |  j j |	 ƒ |	 j S(
   s6   
        Internal wrapper for setting values.
        s   not connecteds,   Invalid type for key: %s, expecting a strings   Key too longs.   Invalid type for value: %s, expecting a stringRT   s   %s %s %d %d %d%sRJ   R?   RR   (   R-   R	   RP   Rk   Rl   R   Rm   R5   Rn   R0   R   R   R4   R   (
   R   R'   RJ   R>   R?   Rr   R@   RR   Ro   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRq     s*    	c         C   s   |  j  d | | d d d ƒ S(   s˜  
        Append given data to the value of an existing key.

        @param key: The key to modify.
        @type key: C{str}

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

        @return: A deferred that will fire with C{True} if the operation has
            succeeded, C{False} otherwise.
        @rtype: L{Deferred}
        R4   i    R2   (   Rq   (   R   RJ   R>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR4   0  s    c         C   s   |  j  d | | d d d ƒ S(   sš  
        Prepend given data to the value of an existing key.

        @param key: The key to modify.
        @type key: C{str}

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

        @return: A deferred that will fire with C{True} if the operation has
            succeeded, C{False} otherwise.
        @rtype: L{Deferred}
        t   prependi    R2   (   Rq   (   R   RJ   R>   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRv   C  s    c         C   s   |  j  | g | t ƒ S(   s¼  
        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: C{str}

        @param withIdentifier: If set to C{True}, retrieve the current
            identifier along with the value and the flags.
        @type withIdentifier: C{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 C{None} and
            the returned flags will be C{0}.
        @rtype: L{Deferred}
        (   t   _getRC   (   R   RJ   t   withIdentifier(    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRE   V  s    c         C   s   |  j  | | t ƒ S(   s  
        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: C{list} of C{str}

        @param withIdentifier: If set to C{True}, retrieve the identifiers
            along with the values and the flags.
        @type withIdentifier: C{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 C{None} and the returned flags
            will be C{0}.
        @rtype: L{Deferred}

        @since: 9.0
        (   Rw   R,   (   R   RO   Rx   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   getMultipleo  s    c   	      C   sG  |  j  r t t d ƒ ƒ Sx_ | D]W } t | t ƒ sR t t d t | ƒ f ƒ ƒ St | ƒ |  j k r  t t d ƒ ƒ Sq  W| rŠ d } n d } d | d j	 | ƒ f } |  j
 | ƒ | rt g  | D] } | d f ^ qÆ ƒ } t | d
 | d | d t ƒ} n. t | d | d d d d d d d	 d t ƒ} |  j j | ƒ | j S(   s>   
        Helper method for C{get} and C{getMultiple}.
        s   not connecteds,   Invalid type for key: %s, expecting a strings   Key too longRF   RE   s   %s %sRT   i    R2   RO   R8   R7   RJ   R   R?   R@   N(   i    R2   N(   R-   R	   RP   Rk   Rl   R   Rm   R5   Rn   R6   R0   RH   R    R   R,   RC   R   R4   R   (	   R   RO   Rx   R7   RJ   R'   Ro   R8   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRw   ‰  s(    		%!%	c         C   sh   | r d | } n d } |  j  r2 t t d ƒ ƒ S|  j | ƒ t d d i  ƒ} |  j j | ƒ | j S(   sï  
        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{NoneType} or L{str}

        @return: a deferred that will fire with a C{dict} of the available
            statistics.
        @rtype: L{Deferred}
        s   stats RG   s   not connectedR8   (   R-   R	   RP   R0   R   R   R4   R   (   R   t   argR'   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyRG   ¤  s    	c         C   sI   |  j  r t t d ƒ ƒ S|  j d ƒ t d ƒ } |  j j | ƒ | j S(   sª   
        Get the version of the server.

        @return: a deferred that will fire with the string value of the
            version.
        @rtype: L{Deferred}
        s   not connectedt   version(   R-   R	   RP   R0   R   R   R4   R   (   R   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR{   ¾  s    	c         C   s   |  j  r t t d ƒ ƒ St | t ƒ sE t t d t | ƒ f ƒ ƒ S|  j d | ƒ t d d | ƒ} |  j	 j
 | ƒ | j S(   s  
        Delete an existing C{key}.

        @param key: the key to delete.
        @type key: C{str}

        @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}
        s   not connecteds,   Invalid type for key: %s, expecting a strings	   delete %st   deleteRJ   (   R-   R	   RP   Rk   Rl   R   Rm   R0   R   R   R4   R   (   R   RJ   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR|   Î  s    	c         C   sI   |  j  r t t d ƒ ƒ S|  j d ƒ t d ƒ } |  j j | ƒ | j S(   s·   
        Flush all cached values.

        @return: a deferred that will be called back with C{True} when the
            operation has succeeded.
        @rtype: L{Deferred}
        s   not connectedt	   flush_all(   R-   R	   RP   R0   R   R   R4   R   (   R   Rp   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   flushAllä  s    	N(,   R   R   R   Rn   RC   R-   R   R(   R+   R.   R0   RA   RB   RD   RK   RL   RS   RU   RW   RY   R[   R\   R]   R^   R_   Re   Rh   Rj   Rg   Rb   Rs   Rt   Ru   Rq   R4   Rv   RE   Ry   Rw   R    RG   R{   R|   R~   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyR   p   sP   																																	t   DEFAULT_PORTN(   R   t   collectionsR    t   ImportErrort   listt   twisted.protocols.basicR   t   twisted.protocols.policiesR   t   twisted.internet.deferR   R	   R
   t   twisted.pythonR   R   t	   ExceptionR   R   R   t   objectR   R   t   __all__(    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/protocols/memcache.pyt   <module>   s$   ,ÿ ÿ ‡