![]() |
Atomically increments a key's value.
google.appengine.api.memcache.incr(
key, delta=1, namespace=None, initial_value=None
)
Internally, the value is a unsigned 64-bit integer. Memcache doesn't check 64-bit overflows. The value, if too large, will wrap around.
Unless an initial_value is specified, the key must already exist
in the cache to be incremented. To initialize a counter, either
specify initial_value or set()
it to the initial value, as an
ASCII decimal integer. Future get()
s of the key, post-increment,
will still be an ASCII decimal value.
Args | |
---|---|
key
|
Key to increment. If an iterable collection, each one of the keys will be offset. See Client's docstring for details. |
delta
|
Non-negative integer value (int or long) to increment key by, defaulting to 1. |
namespace
|
a string specifying an optional namespace to use in the request. |
initial_value
|
initial value to put in the cache, if it doesn't already exist. The default value, None, will not create a cache entry if it doesn't already exist. |
Returns | |
---|---|
If key was a single value, the new long integer value, or None if key
was not in the cache, could not be incremented for any other reason, or
a network/RPC/server error occurred.
If key was an iterable collection, a dictionary will be returned mapping supplied keys to values, with the values having the same meaning as the singular return value of this method. |
Raises | |
---|---|
ValueError
|
If number is negative. |
TypeError
|
If delta isn't an int or long. |