Interface to a set of memcached servers.
servers is a sequence of strings specifying the servers to use.
binary specifies whether or not to use the binary protocol to talk to the memcached servers.
Supported transport mechanisms are TCP, UDP and UNIX domain sockets. The default transport type is TCP.
To specify UDP, the server address should be prefixed with "udp:", as in "udp:127.0.0.1".
To specify UNIX domain socket, the server address must contain a slash, as in "./foo.sock".
Mixing transport types is prohibited by pylibmc as this is not supported by libmemcached.
Get each of the keys in sequence keys.
If key_prefix is given, specifies a string to prefix each of the values in keys with.
Returns a mapping of each unprefixed key to its corresponding value in memcached. If a key doesn’t exist, no corresponding key is set in the returned mapping.
Set key to value.
| Parameters: |
|
|---|
If time is given, it specifies the number of seconds until key will expire. Default behavior is to never expire (equivalent of specifying 0).
If min_compress_len is given, it specifies the maximum number of actual bytes stored in memcached before compression is used. Default behavior is to never compress (which is what 0 means). See Compression.
Set multiple keys as given by mapping.
If key_prefix is specified, each of the keys in mapping is prepended with this value.
Returns a list of keys which were not set for one reason or another, without their optional key prefix.
Sets key if it does not exist.
See also
set(), replace()
Sets key only if it already exists.
See also
set(), add()
Append value to key (i.e., m[k] = m[k] + v).
Note
Uses memcached’s appending support, and therefore should never be used on keys which may be compressed or non-string values.
Prepend value to key (i.e., m[k] = v + m[k]).
Note
Uses memcached’s prepending support, and therefore should never be used on keys which may be compressed or non-string values.
Increment value at key by delta.
Returns the new value for key, after incrementing.
Works for both strings and integer types.
Note
There is currently no way to set a default for key when incrementing.
Decrement value at key by delta.
Returns the new value for key, after decrementing.
Works for both strings and integer types, but will never decrement below zero.
Note
There is currently no way to set a default for key when decrementing.
Delete key if it exists.
If time is non-zero, this is equivalent of setting an expiry time for a key, i.e., the key will cease to exist after that many seconds.
Returns True if the key was deleted, False otherwise (as is the case if it wasn’t set in the first place.)
Note
Some versions of libmemcached are unable to set time for a delete. This is true of versions up until at least 0.38.
Delete each of key in the sequence keys.
| Parameters: |
|
|---|
If time is zero, the keys are deleted immediately.
Returns True if all keys were successfully deleted, False otherwise (as is the case if it wasn’t set in the first place.)
Disconnect from all servers and reset internal state.
Exposed mainly for compatibility with python-memcached, as there really is no logical reason to do this.
Flush all data from all servers.
Note
This clears the specified memcacheds fully and entirely.
Retrieve statistics from each of the connected memcached instances.
Returns a list of two-tuples of the format (name, stats).
stats is a mapping of statistics item names to their values. Whether or not a key exists depends on the version of libmemcached and memcached used.