English ▼
Skip to page content Skip to main navigation
e.g. "templates" or "datastore"

# The Client Class

The Memcache API provides a class-based interface for compatibility with other Memcache APIs. See also the function interface, which provides identical functionality, except for features that support compare and set (cas) functionality, such as cas(), cas_multi(), cas_reset(), and gets(), which are available only through the Client object.

The `Client` class is provided by the `google.appengine.api.memcache` module.

- Introduction
- Client()
- Instance methods:
  - set()
  - set_multi()
  - get()
  - get_multi()
  - delete()
  - delete_multi()
  - add()
  - add_multi()
  - delete()
  - replace()
  - replace_multi()
  - incr()
  - decr()
  - offset_multi()
  - flush_all()
  - get_stats()
  - gets()
  - cas()
  - cas_multi()
  - cas_reset()
  - create_rpc()
  - set_multi_async()
  - cas_multi_async()
  - get_multi_async()
  - delete_multi_async()
  - add_multi_async()
  - replace_multi_async()
  - incr_async()
  - decr_async()
  - offset_multi_async()
  - flush_all_async()
  - get_stats_async()
- Memcached Compatibility

## Introduction

As a developer, you invoke all memcache operations through the Memcache client object

Several methods are no-ops and some method values are ignored to retain source-level compatibility with the existing popular Python memcache library. For example, Google App Engine deals with the sharding transparently but still allows any method that takes a 'key' argument will accept that key as a string or a tuple of (hash_value, string). Generally that hash_value, is used for sharding onto a memcache instance but with App Engine it is ignored. See Memcached Compatibility for more information.

Notice that the memcache Client class supports two different ways to update values. The first way is to use get() or get_multi() to get the values and set() or set_multi() to write the values.

The second way to update values is to take advantage of the compare and set functionality, using gets() (or get_multi() with the for_cas param set to True) to get the values and cas() or cas_multi() to update the values. For more information see Using Compare and Set in Python.

## Constructor

class Client()

  A client for communicating with the Memcache service.

## Instance Methods

A Client instance has the following methods:

set(key, value, time=0, min_compress_len=0, namespace=None)

  Sets a key's value, regardless of previous contents in cache.

  Arguments:

  key
    Key to set. The Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  value
    Value to set. The value type can be any value supported by the Python `pickle` module for serializing values. The combined size of the serialized key and value must be at most 1 megabyte.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the key.

  The return value is True if set, False on error.

set_multi(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None)

  Set multiple keys' values at once. Reduces the network latency of doing many requests in serial.

  Arguments:

  mapping
    Dictionary of keys to values. See set() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to prepend to all keys.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.

  The return value is a list of keys whose values were NOT set. On total success, this list should be empty.

get(key, namespace=None)

  Looks up a single key in memcache.

  Arguments:

  key
    The key in memcache to look up. The Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  namespace
    An optional namespace for the key.

  The return value is the value of the key, if found in memcache, else None.

get_multi(keys, key_prefix='', namespace=None, for_cas=False)

  Looks up multiple keys from memcache in one operation. This is the recommended way to do bulk loads.

  The combined size of all values returned must not exceed 32 megabytes.

  Arguments:

  keys
    List of keys to look up. A Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  key_prefix
    Prefix to prepend to all keys when talking to the server; not included in the returned dictionary.
  namespace
    An optional namespace for the keys.
  for_cas
    If called in the function interface, this value must be set to false. If called as a Client instance method, supply the value True if you wish to use the compare and set (cas) feature or supply the value False if you don't want to use that feature.

  The returned value is a dictionary of the keys and values that were present in memcache. Even if the key_prefix is specified, that key_prefix is not included on the keys in the returned dictionary.

delete(key, seconds=0, namespace=None)

  Deletes a key from memcache.

  Arguments:

  key
    Key to delete. A Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  seconds
    Optional number of seconds to make deleted items 'locked' for 'add' operations. Value can be a delta from current time (up to 1 month), or an absolute Unix epoch time. Defaults to 0, which means items can be immediately added. With or without this option, a 'set' operation will always work. Float values will be rounded up to the nearest whole second.
  namespace
    An optional namespace for the key.

  The return value is 0 (DELETE_NETWORK_FAILURE) on network failure, 1 (DELETE_ITEM_MISSING) if the server tried to delete the item but didn't have it, and 2 (DELETE_SUCCESSFUL) if the item was actually deleted. This can be used as a boolean value, where a network failure is the only bad condition.

delete_multi(keys, seconds=0, key_prefix='', namespace=None)

  Delete multiple keys at once.

  Arguments:

  keys
    List of keys to delete. A Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  seconds
    Optional number of seconds to make deleted items 'locked' for 'add' operations. Value can be a delta from current time (up to 1 month), or an absolute Unix epoch time. Defaults to 0, which means items can be immediately added. With or without this option, a 'set' operation will always work. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. See docs for get_multi() and set_multi()
  namespace
    An optional namespace for the keys.

  The return value is True if all operations completed successfully. False if one or more failed to complete.

add(key, value, time=0, min_compress_len=0, namespace=None)

  Sets a key's value, if and only if the item is not already in memcache.

  Arguments:

  key
    Key to set. The Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance is instead ignored, as Google App Engine deals with the sharding transparently.
  value
    Value to set. The value type can be any value supported by the Python `pickle` module for serializing values. The combined size of the serialized key and value must be at most 1 megabyte.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the key.

  The return value is True if added, False on error.

add_multi(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None)

  Adds multiple values at once, with no effect for keys already in memcache.

  Arguments:

  mapping
    A mapping of keys to values. See add() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. Even if the key_prefix is specified, that key_prefix won't be on the keys in the returned list. See get_multi().
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.

  The return value is a list of keys whose values were not set because they were already set in memcache, or an empty list.

replace(key, value, time=0, min_compress_len=0, namespace=None)

  Replaces a key's value, failing if item isn't already in memcache.

  Arguments:

  key
    Key to set. The Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  value
    Value to set. The value type can be any value supported by the Python `pickle` module for serializing values. The combined size of the serialized key and value must be at most 1 megabyte.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the key.

  The return value is True if replaced. False on error or cache miss.

replace_multi(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None)

  Replaces multiple values at once, with no effect for keys not in memcache.

  Arguments:

  mapping
    A mapping of keys to values. See replace() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. Even if the key_prefix is specified, that key_prefix won't be on the keys in the returned list. See get_multi().
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.

  The return value is a list of keys whose values were not set because they were not set in memcache, or an empty list.

incr(key, delta=1, namespace=None, initial_value=None)

  Atomically increments a key's value. Internally, the value is a unsigned 64-bit integer. Memcache doesn't check 64-bit overflows. The value, if too large, will wrap around.

  If the key does not yet exist in the cache and you specify an initial_value, the key's value will be set to this initial value and then incremented. If the key does not exist and no initial_value is specified, the key's value will not be set.

  Arguments:

  key
    Key to increment, or a list of keys to increment. Each Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  delta
    Non-negative integer value (int or long) to increment key by, defaulting to 1.
  namespace
    An optional namespace for the key.
  initial_value
    An initial value to be used if the key does not yet exist in the cache. Ignored if the key already exists. If `None` and the key does not exist, the key remains unset.

  The return value is a new long integer value, or None if key was not in the cache or could not be incremented for any other reason.

decr(key, delta=1, namespace=None, initial_value=None)

  Atomically decrements a key's value. Internally, the value is a unsigned 64-bit integer. Memcache doesn't check 64-bit overflows. The value, if too large, will wrap around.

  If the key does not yet exist in the cache and you specify an initial_value, the key's value will be set to this initial value and then decremented. If the key does not exist and no initial_value is specified, the key's value will not be set.

  Arguments:

  key
    Key to decrement, or a list of keys to decrement. Each Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  delta
    Non-negative integer value (int or long) to decrement key by, defaulting to 1.
  namespace
    An optional namespace for the key.
  initial_value
    An initial value to be used if the key does not yet exist in the cache. Ignored if the key already exists. If `None` and the key does not exist, the key remains unset.

  The return value is a new long integer value, or None if key was not in the cache or could not be decremented for any other reason.

offset_multi(mapping, key_prefix='', namespace=None, initial_value=None)

  Increments or decrements multiple keys with integer values in a single service call. Each key can have a separate offset. The offset can be positive or negative.

  Applying an offset to a single key is atomic. Applying an offset to multiple keys may succeed for some keys and fail for others.

  Arguments:

  mapping
    Dictionary of keys to offsets. An offset can be a positive or negative integer to be added to the key's value.
  key_prefix
    Prefix to prepend to all keys.
  namespace
    An optional namespace for all keys in the mapping.
  initial_value
    An initial value to be used if a key in the mapping does not yet exist in the cache. If `None` and a key in the mapping does not exist in the cache, the key remains unset in the cache.

  The return value is a mapping of the provided keys to their new values. If there was an error applying an offset to a key, if a key doesn't exist in the cache and no `initial_value` is provided, or if a key is set with a non-integer value, its return value is `None`.

flush_all()

  Deletes everything in memcache.

  The return value is True on success, False on RPC or server error.

get_stats()

  Gets memcache statistics for this application. All of these statistics may reset due to various transient conditions. They provide the best information available at the time of being called.

  The return value is a dictionary mapping statistic names to associated values. Statistics and their associated meanings:

  `hits`
    Number of cache get requests resulting in a cache hit.
  `misses`
    Number of cache get requests resulting in a cache miss.
  `byte_hits`
    Sum of bytes transferred on get requests. Rolls over to zero on overflow.
  `items`
    Number of key/value pairs in the cache.
  `bytes`
    Total size of all items in the cache.
  `oldest_item_age`
    How long in seconds since the oldest item in the cache was accessed. Effectively, this indicates how long a new item will survive in the cache without being accessed. This is not the amount of time that has elapsed since the item was created.

cas(key, value, time=0, min_compress_len=0, namespace=None)

  Performs a "compare and set" update to a value that was fetched by a method that supports compare and set, such as gets() or get_multi() with its for_cas param set to True. This method internally adds the cas_id timestamp fetched with the value by `gets()` to the request it sends to the memcache service. The service then compares the timestamp received to the timestamp currently associated with the value. If they match, the memcache service updates the value and the timestamp, and returns success. If they don't match, it leaves the value and timestamp alone, and returns failure. (By the way, the service does not send the new timestamp back with a successful response. The only way to retrieve the cas_id timestamp is to call `gets()`.)

  Note: The cas_id is a hidden value, handled internally and automatically by the methods that support compare and set. You don't do anything explicit in your code to read, write, or manipulate cas_ids.

  Arguments:

  key
    Key to set. The Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  value
    Value to set. The value type can be any value supported by the Python `pickle` module for serializing values. The combined size of the serialized key and value must be at most 1 megabyte.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the key.

  The return value is True if the value is successfully updated in memcache, False on an RPC error or if the cas_id value doesn't match the one currently in memcache for that value.

cas_multi(mapping, time=0, key_prefix='', namespace=None, rpc=None)

  Sets multiple values at the same time, reducing the network latency of doing many requests in serial, using values fetched by gets() or get_multi() with its for_cas param set to True. This method is similar to cas() but works on multiple values.

  Arguments:

  mapping
    Dictionary of keys to values. A map from key to new_value where the key must have previously been retrieved by gets() or get_multi() with for_cas set to true. See set() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to prepend to all keys.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.

  Returns a list of keys. If there is complete success, the list is empty. If another caller has changed a value after you retrieved it using gets() or get_multi call and before your attempt to update that value, the write attempt will fail and that value is returned in the list.

cas_reset( )

  Clears all of the cas_ids from the current Client object.

  No return value.

cas_multi_async(mapping, time=0, key_prefix='', namespace=None, rpc=None)

  Asynchronously sets multiple values at the same time, reducing the network latency of doing many requests in serial, using values fetched by gets() or get_multi() with its for_cas param set to True. Before this call does the update, for each value it is updating it compares the cas_id of the value when it was fetched to the current cas_id of the value in memcache. If there is a match, memcache is updated with the new value. If the two cas_id values don't match, this means the value was updated some time between the fetch and the attempt to update, and so this method does not update the value in memcache. This call can be partially successful, where some values are written to memcache and some are not. (This method returns the key values that could not be updated.)

  Arguments:

  mapping
    Dictionary of keys to values. A map from key to new_value where the key must have previously been retrieved by gets() or get_multi() with for_cas set to true. See set() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to prepend to all keys.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.
  rpc
    The RPC object used in the asynchronous request.

  Returns the RPC instance whose get_result() method returns None if there was a network error. If there is no error, returns a dict mapping (user) keys to status values where each status is one of `STORED`, `NOT_STORED`, `ERROR`, or `EXISTS`.

create_rpc(deadline=None), callback=None)

  Creates an RPC object for use with async calls. An application calls asynchronously to perform the operation in the background while the application does other things. To set up the async call, the application first calls create_rpc() to create an RPC object used for the async call. Next, the async call is made, passing the RPC object as an argument. The async call returns immediately, freeing your app to do other things. When your app is ready for the results, it calls the get_result() method directly on the RPC object.

  Notice that the deadline is set in time of seconds, whereas data is usually returned within milliseconds. This means that you normally don't need to set the deadline.

  Arguments:

  deadline
    Optional deadline in seconds for the operation. Normally, you would not need to specify a deadline because the return is from async calls are made in milliseconds, faster than the deadline.
  callback
    An optional function to be called when the async call completes.

  Returns an RPC object for use in the async calls.

set_multi_async(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None, rpc=None)

  Asynchronously sets multiple keys' values at once, asynchronous. Reduces the network latency of doing many requests in serial.

  Arguments:

  mapping
    Dictionary of keys to values. See set() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to prepend to all keys.
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.
  rpc
    The RPC object used for asynchronous operation.

  Returns an RPC instance whose get_result() method returns None if there was a network error, or else returns a dict mapping (user) keys to status values where each status is one of `STORED`, `NOT_STORED`, `ERROR`, or `EXISTS`.

get_multi_async(keys, key_prefix='', namespace=None), for_cas=False), rpc=None)

  Asynchronously looks up multiple keys from memcache in one operation. This is the recommended way to do bulk loads.

  The combined size of all values returned must not exceed 32 megabytes.

  Arguments:

  keys
    List of keys to look up. A Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  key_prefix
    Prefix to prepend to all keys when talking to the server; not included in the returned dictionary.
  namespace
    An optional namespace for the keys.
  for_cas
    The value True indicates that cas_id is returned and used, so the key values must be written back using an update method that supports cas_id, such as cas(), or cas_multi(). The value False means there is no cas support and you use the set methods that don't use cas_id.
  rpc
    The RPC object used for async operations.

  The returned value is a dictionary of the keys and values that were present in memcache. Even if the key_prefix is specified, that key_prefix is not included on the keys in the returned dictionary.

get_stats_async()

  Gets memcache statistics for this application asynchronously. All of these statistics may reset due to various transient conditions. They provide the best information available at the time of being called.

  The return value is a dictionary mapping statistic names to associated values. Statistics and their associated meanings:

  `hits`
    Number of cache get requests resulting in a cache hit.
  `misses`
    Number of cache get requests resulting in a cache miss.
  `byte_hits`
    Sum of bytes transferred on get requests. Rolls over to zero on overflow.
  `items`
    Number of key/value pairs in the cache.
  `bytes`
    Total size of all items in the cache.
  `oldest_item_age`
    How long in seconds since the oldest item in the cache was accessed. Effectively, this indicates how long a new item will survive in the cache without being accessed. This is not the amount of time that has elapsed since the item was created.
flush_all_async()

  Asynchronously deletes everything in memcache.

  The return value is True on success, False on RPC or server error.

delete_multi_async(keys, seconds=0, key_prefix='', namespace=None, rpc=None))

  Asynchronously deletes multiple keys at once.

  Arguments:

  keys
    List of keys to delete. A Key can be a string or a tuple of (hash_value, string) where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  seconds
    Optional number of seconds to make deleted items 'locked' for 'add' operations. Value can be a delta from current time (up to 1 month), or an absolute Unix epoch time. Defaults to 0, which means items can be immediately added. With or without this option, a 'set' operation will always work. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. See docs for get_multi() and set_multi()
  namespace
    An optional namespace for the keys.
  rpc
    The RPC object used for async operations

  An RPC instance whose get_result() method returns None if there was a network error, or else returns a list of status values, where each status corresponds to a key and is either DELETED or NOT_FOUND.

add_multi_async(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None, rpc=None)

  Asynchronously adds multiple values at once, with no effect for keys already in memcache.

  Arguments:

  mapping
    A mapping of keys to values. See add() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. Even if the key_prefix is specified, that key_prefix won't be on the keys in the returned list. See get_multi().
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.
  rpc
    The RPC object used for the asynchronous request.

  Returns the RPC instance whose get_result() method returns None if there was a network error. If there is no error, returns a dict mapping (user) keys to status values where each status is one of `STORED`, `NOT_STORED`, `ERROR`, or `EXISTS`.

gets(key, namespace=None)

  Looks up a single key in memcache and fetches its cas_id as well. You use this method rather than `get()` if you want to avoid conditions in which two or more callers are trying to modify the same key value at the same time, leading to undesired overwrites. This method fetches the key value and the key value's current cas_id, which is required for `cas()` and `cas_multi()` calls. (The cas_id is handled for you automatically by this call.)

  Arguments:

  key
    The key in memcache to look up. The Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  namespace
    An optional namespace for the key.

  The return value is the value of the key, if found in memcache, else None.

replace_multi_async(mapping, time=0, key_prefix='', min_compress_len=0, namespace=None, rpc=None)

  Asynchronously replaces multiple values at once, with no effect for keys not in memcache.

  Arguments:

  mapping
    A mapping of keys to values. See replace() for a description of allowed keys and values. The combined size of all keys and values must be at most 32 megabytes.
  time
    Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time. By default, items never expire, though items may be evicted due to memory pressure. Float values will be rounded up to the nearest whole second.
  key_prefix
    Prefix to put on all keys when sending specified keys to memcache. Even if the key_prefix is specified, that key_prefix won't be on the keys in the returned list. See get_multi().
  min_compress_len
    Ignored option for compatibility.
  namespace
    An optional namespace for the keys.
  rpc
    The RPC object used for the asynchronous request.

  Returns the RPC instance whose get_result() method returns None if there was a network error. If there is no error, returns a dict mapping (user) keys to status values where each status is one of `STORED`, `NOT_STORED`, `ERROR`, or `EXISTS`.

incr_async(key, delta=1, namespace=None, initial_value=None, rpc=rpc</span)</dt>

  Asynchronously and atomically increments on a key's value. Internally, the value is a unsigned 64-bit integer. Memcache doesn't check 64-bit overflows. The value, if too large, will wrap around.

  If the key does not yet exist in the cache and you specify an initial_value, the key's value will be set to this initial value and then incremented. If the key does not exist and no initial_value is specified, the key's value will not be set.

  Arguments:

  key
    Key to increment, or a list of keys to increment. Each Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  delta
    Non-negative integer value (int or long) to increment key by, defaulting to 1.
  namespace
    An optional namespace for the key.
  initial_value
    An initial value to be used if the key does not yet exist in the cache. Ignored if the key already exists. If `None` and the key does not exist, the key remains unset.
  rpc
    The RPC object used for the asynchronous request.

  The return value is a new long integer value, or None if key was not in the cache or could not be incremented for any other reason.

decr_async(key, delta=1, namespace=None, initial_value=None,rpc=rpc)

  Asynchronously and atomically decrements a key's value. Internally, the value is a unsigned 64-bit integer. Memcache doesn't check 64-bit overflows. The value, if too large, will wrap around.

  If the key does not yet exist in the cache and you specify an initial_value, the key's value will be set to this initial value and then decremented. If the key does not exist and no initial_value is specified, the key's value will not be set.

  Arguments:

  key
    Key to decrement, or a list of keys to decrement. Each Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
  delta
    Non-negative integer value (int or long) to decrement key by, defaulting to 1.
  namespace
    An optional namespace for the key.
  initial_value
    An initial value to be used if the key does not yet exist in the cache. Ignored if the key already exists. If `None` and the key does not exist, the key remains unset.
  rpc
    The RPC object used for the asynchronous request.

  The return value is a new long integer value, or None if key was not in the cache or could not be decremented for any other reason.

offset_multi_async(mapping, key_prefix='', namespace=None, initial_value=None, rpc=None)

  Asynchronously increments or decrements multiple keys with integer values in a single service call. Each key can have a separate offset. The offset can be positive or negative.

  Applying an offset to a single key is atomic. Applying an offset to multiple keys may succeed for some keys and fail for others.

  Arguments:

  mapping
    Dictionary of keys to offsets. An offset can be a positive or negative integer to be added to the key's value.
  key_prefix
    Prefix to prepend to all keys.
  namespace
    An optional namespace for all keys in the mapping.
  initial_value
    An initial value to be used if a key in the mapping does not yet exist in the cache. If `None` and a key in the mapping does not exist in the cache, the key remains unset in the cache.
  rpc
    The RPC object used for the asynchronous request.

  The return value is a mapping of the provided keys to their new values. If there was an error applying an offset to a key, if a key doesn't exist in the cache and no `initial_value` is provided, or if a key is set with a non-integer value, its return value is `None`.

## Memcached Compatibility

The Client class includes methods and arguments for compatibility with the Memcached API. Because some of these methods and arguments do not apply to the App Engine Memcache service, they have no effect.

Methods provided for compatibility purposes that have no effect in the App Engine Memcache API include the following:

- `disconnect_all()`
- `set_servers(...)`