# Module: google.appengine.api.memcache

<br />

|---|
| [View source on GitHub](https://github.com/GoogleCloudPlatform/appengine-python-standard/tree/main/src/google/appengine/api/memcache/__init__.py) |

Memcache API.

Provides memcached-alike API to application developers to store
data in memory when reliable storage via the DataStore API isn't
required and higher performance is desired.

## Modules

[`memcache_stub`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/memcache_stub) module: Stub version of the memcache API, keeping all data in process memory.

## Classes

[`class Client`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/Client): Memcache client object, through which one invokes all memcache operations.

[`class ItemWithTimestamps`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/ItemWithTimestamps): A Memcache item with its relevant timestamps.

## Functions

[`add(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/add): Sets a key's value if the item is not already in memcache.

[`add_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/add_multi): Set multiple keys' values if items are not already in memcache.

[`create_rpc(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/create_rpc): Creates an RPC object for use with the memcache API.

[`debuglog(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/debuglog): Logging function for debugging information.

[`decr(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/decr): Atomically decrements a key's value.

[`delete(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/delete): Deletes a key from memcache.

[`delete_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/delete_multi): Delete multiple keys at once.

[`disconnect_all(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/disconnect_all): Closes all connections to memcache servers.

[`flush_all(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/flush_all): Deletes everything in memcache.

[`forget_dead_hosts(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/forget_dead_hosts): Resets all servers to the alive status.

[`get(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/get): Looks up a single key in memcache.

[`get_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/get_multi): Looks up multiple keys from memcache in one operation.

[`get_stats(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/get_stats): Gets memcache statistics for this application.

[`incr(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/incr): Atomically increments a key's value.

[`offset_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/offset_multi): Offsets multiple keys by a delta, incrementing and decrementing in batch.

[`peek(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/peek): Gets an item from memcache along with its timestamp metadata.

[`peek_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/peek_multi): Gets multiple items from memcache along with their timestamp metadata.

[`replace(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/replace): Replaces a key's value, failing if item isn't already in memcache.

[`replace_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/replace_multi): Replace multiple keys' values, failing if the items aren't in memcache.

[`set(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/set): Sets a key's value, regardless of previous contents in cache.

[`set_multi(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/set_multi): Set multiple keys' values at once, regardless of previous contents.

[`set_servers(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/set_servers): Sets the pool of memcache servers used by the client.

[`setup_client(...)`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/memcache/setup_client): Sets the Client object instance to use for all module-level methods.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| CAPABILITY | Instance of [`google.appengine.api.capabilities.CapabilitySet`](https://docs.cloud.google.com/appengine/docs/standard/python3/reference/services/bundled/google/appengine/api/capabilities/CapabilitySet) |
| DELETE_ITEM_MISSING | `1` |
| DELETE_NETWORK_FAILURE | `0` |
| DELETE_SUCCESSFUL | `2` |
| ERROR | `3` |
| EXISTS | `4` |
| FLAG_COMPRESSED | `8` |
| FLAG_TYPE_MASK | `7` |
| MAX_KEY_SIZE | `250` |
| MAX_VALUE_SIZE | `1000000` |
| NOT_STORED | `2` |
| STAT_BYTES | `'bytes'` |
| STAT_BYTE_HITS | `'byte_hits'` |
| STAT_HITS | `'hits'` |
| STAT_ITEMS | `'items'` |
| STAT_MISSES | `'misses'` |
| STAT_OLDEST_ITEM_AGES | `'oldest_item_age'` |
| STORED | `1` |
| TYPE_BOOL | `5` |
| TYPE_INT | `3` |
| TYPE_LONG | `4` |
| TYPE_PICKLED | `2` |
| TYPE_STR | `0` |
| TYPE_UNICODE | `1` |

<br />