Memcached incr and decr command
Memcached incr and decr command is used to key (key) numeric value already exists will be incrementing or subtraction operation.
Data incr and decr operation of the command must be a decimal 32-bit unsigned integer.
If the key does not exist returnNOT_FOUND, if the value of the key is not a number, the return CLIENT_ERROR,other errors returnERROR.
incr command
grammar:
The basic syntax incr command is as follows:
incr key increment_value
Parameters are as follows:
- key: key key-value structure key, it is used to find the cache value.
- increment_value: increase the value.
Examples
In the following examples, we use visitors as key, an initial value of 10, followed by adding 5 operation.
set visitors 0 900 2 10 STORED get visitors VALUE visitors 0 2 10 END incr visitors 5 15 get visitors VALUE visitors 0 2 15 END
Export
Output information Description:
- NOT_FOUND: key does not exist.
- CLIENT_ERROR: Since the value is not an object.
- ERROR other errors, such as syntax errors.
decr command
The basic syntax decr command is as follows:
decr key decrement_value
Parameters are as follows:
- key: key key-value structure key, it is used to find the cache value.
- decrement_value: reduce value.
Examples
set visitors 0 900 2 10 STORED get visitors VALUE visitors 0 2 10 END decr visitors 5 5 get visitors VALUE visitors 0 1 5 END
In the following examples, we use visitors as key, an initial value of 10, followed by minus 5 operation.
Export
Output information Description:
- NOT_FOUND: key does not exist.
- CLIENT_ERROR: Since the value is not an object.
- ERROR other errors, such as syntax errors.