File: //usr/lib/python3/dist-packages/twisted/protocols/__pycache__/memcache.cpython-310.pyc
o
�bc\ � @ s� d Z ddlmZ ddlmZmZmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dZG d d
� d
e�ZG dd� de�ZG d
d� de�ZG dd� d�ZG dd� dee
�Zg d�ZdS )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 @ � 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 ( � r c @ r )�ClientErrorz1
Error caused by an invalid client call.
Nr
r r r r r . r r c @ r )�ServerErrorz*
Problem happening on the server.
Nr
r r r r r 4 r 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__G s
�zCommand.__init__c C � | j �|� dS )zB
Shortcut method to fire the underlying deferred.
N)r �callback)r �valuer r r �successV � zCommand.successc C r! )z5
Make the underlying deferred fails.
N)r �errback)r �errorr r r r \ r% zCommand.failN)r r r r r r$ r r r r r r : s
r c @ sT e Zd ZdZdZdZdRdd�Zdd� Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� ZdSd.d/�ZdSd0d1�Zd2d3� ZdTd5d6�ZdTd7d8�ZdTd9d:�ZdTd;d<�Z d=d>� Z!d?d@� Z"dAdB� Z#dUdCdD�Z$dUdEdF�Z%dGdH� Z&dVdJdK�Z'dLdM� Z(dNdO� Z)dPdQ� Z*dIS )W�MemCacheProtocola1
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}
� F�<