File: //lib/python3/dist-packages/twisted/protocols/__pycache__/memcache.cpython-38.pyc
U
W[�\ � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl
mZmZm
Z
ddlmZ ddlmZmZmZmZ d ZG d
d� de�ZG dd
� d
e�ZG dd� de�ZG dd� de�ZG dd� dee �Zdddd
dgZdS )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.
� )�absolute_import�division)�deque)�LineReceiver)�TimeoutMixin)�Deferred�fail�TimeoutError)�log)�
intToBytes� iteritems�nativeString�
networkStringi�+ c @ s e Zd ZdZdS )�
NoSuchCommandzA
Exception raised when a non existent command is called.
N��__name__�
__module__�__qualname__�__doc__� r r �</usr/lib/python3/dist-packages/twisted/protocols/memcache.pyr - s r c @ s e Zd ZdZdS )�ClientErrorz1
Error caused by an invalid client call.
Nr r r r r r 4 s r c @ s e Zd ZdZdS )�ServerErrorz*
Problem happening on the server.
Nr r r r r r ; s r c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �Commanda8
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 K s0 || _ t� | _|�� D ]\}}t| ||� qdS )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�vr r r �__init__O s
zCommand.__init__c C s | j �|� dS )zB
Shortcut method to fire the underlying deferred.
N)r �callback)r �valuer r r �success_ s zCommand.successc C s | j �|� dS )z5
Make the underlying deferred fails.
N)r Zerrback)r �errorr r r r f s zCommand.failN)r r r r r"