Memcached incr and decr command is used for existing key the numeric value of (key) is used for self-increasing or self-decreasing operation.
incr and decr the data for the command operation must be a decimal 32-bit unsigned integer.
If The The parameters are described as follows: In the following example, we use the Output information description: The The parameters are described as follows: In the following example, we use the Output information description: key has no return NOT_FOUND , the value of the key is nota number, returns CLIENT_ERROR other errors are returned ERROR . 1.14.1.
incr command ¶ Syntax: ¶
incr basic syntax format of the command is as follows:incr key increment_value
key :Key value key-value in the structure key used to find cached values increment_value :The increased number. 1.14.2. Example ¶
visitors as key the initial value is 10, and then add 5.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
1.14.3. Output ¶
NOT_FOUND : key doesn’t exist. CLIENT_ERROR :Self-increment is not an object. ERROR other errors, such as grammatical errors. 1.14.4.
decr command ¶ decr basic syntax format of the command is as follows:decr key decrement_value
key :Key value key-value in the structure key used to find cached values decrement_value :The reduced number.Example ¶
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
visitors as key with an initial value of 10, followed by minus 5 1.14.5. Output ¶
NOT_FOUND : key doesn’t exist. CLIENT_ERROR :Self-increment is not an object. ERROR other errors, such as grammatical errors.