The decrement methods reduce the value of a given key if the corresponding value can be parsed to an integer value. These operations are provided at a protocol level to eliminate the need to get, update, and reset a simple integer value in the database. All the Python Client Library methods support the use of an explicit offset value that will be used to reduce the stored value in the database.
| API Call | object.decr(key [, offset ] [, defaultvalue ] [, expiry ]) | ||
| Asynchronous | no | ||
| Description | Decrement the value of an existing numeric key. The Couchbase Server stores numbers as unsigned values. Therefore the lowest you can decrement is to zero. | ||
| Returns | object (
Binary object
) | ||
| Arguments | |||
key | Document ID used to identify the value | ||
offset | Integer offset value to increment/decrement (default 1) | ||
defaultvalue | Value to be stored if key does not already exist | ||
expiry | Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch). | ||
The first form of the decr() method
accepts the keyname and offset value to be used when reducing the
server-side integer. For example, to decrement the server integer
dlcounter by 5:
membase.decr("dlcounter",5);The return value is the updated value of the specified key.