twisted.protocols.memcache.MemCacheProtocol(LineReceiver, TimeoutMixin) class documentationtwisted.protocols.memcache
(View In Hierarchy)
MemCache protocol: connect to a memcached server to store/retrieve values.
| Instance Variable | persistentTimeOut | the timeout period used to wait for a response. (type: int) | 
| Method | __init__ | Create the protocol. | 
| Method | timeoutConnection | Close the connection in case of timeout. | 
| Method | connectionLost | Cause any outstanding commands to fail. | 
| Method | sendLine | Override sendLine to add a timeout to response. | 
| Method | rawDataReceived | Collect data for a get. | 
| Method | cmd_STORED | Manage a success response to a set operation. | 
| Method | cmd_NOT_STORED | Manage a specific 'not stored' response to a set operation: this is not an error, but some condition wasn't met. | 
| Method | cmd_END | This the end token to a get or a stat operation. | 
| Method | cmd_NOT_FOUND | Manage error response for incr/decr/delete. | 
| Method | cmd_VALUE | Prepare the reading a value after a get. | 
| Method | cmd_STAT | Reception of one stat line. | 
| Method | cmd_VERSION | Read version token. | 
| Method | cmd_ERROR | A non-existent command has been sent. | 
| Method | cmd_CLIENT_ERROR | An invalid input as been sent. | 
| Method | cmd_SERVER_ERROR | An error has happened server-side. | 
| Method | cmd_DELETED | A delete command has completed successfully. | 
| Method | cmd_OK | The last command has been completed. | 
| Method | cmd_EXISTS | A checkAndSetupdate has failed. | 
| Method | lineReceived | Receive line commands from the server. | 
| Method | increment | Increment the value of keyby given value (default to 1).keymust be consistent with an int. Return the new value. | 
| Method | decrement | Decrement the value of keyby given value (default to 1).keymust be consistent with an int. Return the new value, 
coerced to 0 if negative. | 
| Method | replace | Replace the given key. It must already exist in the 
server. | 
| Method | add | Add the given key. It must not exist in the server. | 
| Method | set | Set the given key. | 
| Method | checkAndSet | Change the content of keyonly if thecasvalue 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. | 
| Method | append | Append given data to the value of an existing key. | 
| Method | prepend | Prepend given data to the value of an existing key. | 
| Method | get | No summary | 
| Method | getMultiple | No summary | 
| Method | stats | Get some stats from the server. It will be available as a dict. | 
| Method | version | Get the version of the server. | 
| Method | delete | Delete an existing key. | 
| Method | flushAll | Flush all cached values. | 
| Instance Variable | _current | current list of requests waiting for an answer from the server. (type: dequeofCommand) | 
| Instance Variable | _lenExpected | amount of data expected in raw mode, when reading for a value. (type: int) | 
| Instance Variable | _getBuffer | current buffer of data, used to store temporary data when reading in raw 
mode. (type: list) | 
| Instance Variable | _bufferLength | the total amount of bytes in _getBuffer. (type:int) | 
| Instance Variable | _disconnected | indicate if the connectionLost has been called or not. (type: bool) | 
| Method | _cancelCommands | Cancel all the outstanding commands, making them fail with reason. | 
| Method | _incrdecr | Internal wrapper for incr/decr. | 
| Method | _set | Internal wrapper for setting values. | 
| Method | _get | Helper method for getandgetMultiple. | 
Inherited from LineReceiver:
| Class Variable | delimiter | The line-ending delimiter to use. By default this is b'\r\n'. | 
| Class Variable | MAX_LENGTH | The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384. | 
| Method | clearLineBuffer | Clear buffered data. | 
| Method | dataReceived | Protocol.dataReceived. Translates bytes into lines, and calls lineReceived (or rawDataReceived, depending on mode.) | 
| Method | setLineMode | Sets the line-mode of this receiver. | 
| Method | setRawMode | Sets the raw mode of this receiver. Further data received will be sent to rawDataReceived rather than lineReceived. | 
| Method | lineLengthExceeded | Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way. | 
Inherited from Protocol (via LineReceiver):
| Method | logPrefix | Return a prefix matching the class name, to identify log messages related to this protocol instance. | 
Inherited from BaseProtocol (via LineReceiver, Protocol):
| Method | makeConnection | Make a connection to a transport and a server. | 
| Method | connectionMade | Called when a connection is made. | 
Inherited from _PauseableMixin (via LineReceiver):
| Method | pauseProducing | Undocumented | 
| Method | resumeProducing | Undocumented | 
| Method | stopProducing | Undocumented | 
Inherited from TimeoutMixin:
| Class Variable | timeOut | The number of seconds after which to timeout the connection. | 
| Method | callLater | Wrapper around reactor.callLaterfor test purpose. | 
| Method | resetTimeout | Reset the timeout count down. | 
| Method | setTimeout | Change the timeout period | 
| Method | __timedOut | Undocumented | 
list)
  Create the protocol.
| Parameters | timeOut | the timeout to wait before detecting that the connection is dead and close 
it. It's expressed in seconds. (type: int) | 
Cancel all the outstanding commands, making them fail with 
reason.
Manage a specific 'not stored' response to a set operation: this is not an error, but some condition wasn't met.
Increment the value of key by given value (default to 1). 
key must be consistent with an int. Return the new value.
| Parameters | key | the key to modify. (type: bytes) | 
| val | the value to increment. (type: int) | |
| Returns | a deferred with will be called back with the new value associated with the 
key (after the increment). (type: Deferred) | |
Decrement the value of key by given value (default to 1). 
key must be consistent with an int. Return the new value, 
coerced to 0 if negative.
| Parameters | key | the key to modify. (type: bytes) | 
| val | the value to decrement. (type: int) | |
| Returns | a deferred with will be called back with the new value associated with the 
key (after the decrement). (type: Deferred) | |
Replace the given key. It must already exist in the 
server.
| Parameters | key | the key to replace. (type: bytes) | 
| val | the new value associated with the key. (type: bytes) | |
| flags | the flags to store with the key. (type: int) | |
| expireTime | if different from 0, the relative time in seconds when the key will be 
deleted from the store. (type: int) | |
| Returns | a deferred that will fire with Trueif the operation has 
succeeded, andFalsewith the key didn't previously exist. (type:Deferred) | |
Add the given key. It must not exist in the server.
| Parameters | key | the key to add. (type: bytes) | 
| val | the value associated with the key. (type: bytes) | |
| flags | the flags to store with the key. (type: int) | |
| expireTime | if different from 0, the relative time in seconds when the key will be 
deleted from the store. (type: int) | |
| Returns | a deferred that will fire with Trueif the operation has 
succeeded, andFalsewith the key already exists. (type:Deferred) | |
Set the given key.
| Parameters | key | the key to set. (type: bytes) | 
| val | the value associated with the key. (type: bytes) | |
| flags | the flags to store with the key. (type: int) | |
| expireTime | if different from 0, the relative time in seconds when the key will be 
deleted from the store. (type: int) | |
| Returns | a deferred that will fire with Trueif the operation has 
succeeded. (type:Deferred) | |
Change the content of key only if the 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.
| Parameters | key | The key to set. (type: bytes) | 
| val | The value associated with the key. (type: bytes) | |
| cas | Unique 64-bit value returned by previous call of get. (type:bytes) | |
| flags | The flags to store with the key. (type: int) | |
| expireTime | If different from 0, the relative time in seconds when the key will be 
deleted from the store. (type: int) | |
| Returns | A deferred that will fire with Trueif the operation has 
succeeded,Falseotherwise. (type:Deferred) | |
Get the given key. It doesn't support multiple keys. If 
withIdentifier is set to True, the command issued
is a gets, that will return the current identifier associated 
with the value. This identifier has to be used when issuing 
checkAndSet update later, using the corresponding method.
| Parameters | key | The key to retrieve. (type: bytes) | 
| withIdentifier | If set to True, retrieve the current identifier along with the
value and the flags. (type:bool) | |
| Returns | A deferred that will fire with the tuple (flags, value) if withIdentifierisFalse, or (flags, cas 
identifier, value) ifTrue.  If the server indicates there is 
no value associated withkey, the returned value will beNoneand the returned flags will be0. (type:Deferred) | |
Get the given list of keys.  If withIdentifier
is set to True, the command issued is a gets, 
that will return the identifiers associated with each values. This 
identifier has to be used when issuing checkAndSet update 
later, using the corresponding method.
| Parameters | keys | The keys to retrieve. (type: listofbytes) | 
| withIdentifier | If set to True, retrieve the identifiers along with the values
and the flags. (type:bool) | |
| Returns | A deferred that will fire with a dictionary with the elements of keysas keys and the tuples (flags, value) as values ifwithIdentifierisFalse, or (flags, cas 
identifier, value) ifTrue.  If the server indicates there is 
no value associated withkey, the returned values will beNoneand the returned flags will be0. (type:Deferred) | |
| Present Since | 9.0 | |
Get some stats from the server. It will be available as a dict.
| Parameters | arg | An optional additional string which will be sent along with the 
stats command.  The interpretation of this value by the server is 
left undefined by the memcache protocol specification. (type: Noneorbytes) | 
| Returns | a deferred that will fire with a dictof the available 
statistics. (type:Deferred) | |
Get the version of the server.
| Returns | a deferred that will fire with the string value of the version. (type: Deferred) | |
Flush all cached values.
| Returns | a deferred that will be called back with Truewhen the 
operation has succeeded. (type:Deferred) | |