Increment or decrement Redis values.
redisIncr
increments the Redis string value corresponding to the
specified key by one.
redisDecr
decrements the Redis string value corresponding to the
specified key by one.
The various *By functions increment or decrement values by a specified integer or numeric value.
redisIncr(key) redisIncrBy(key, value) redisIncrByFloat(key, value) redisDecr(key) redisDecrBy(key, value)
key |
A key corresponding to the value to increment. |
value |
The value to increment by (integer, numeric, or character). |
Note that they initial value must be a raw character value (a plain Redis string value), not a serialized R value. See the examples below.
The increment value may be an integer (redisIncrBy
) or a numeric value
(redisIncrByFloat
), or a raw character representation of an integer or
numeric value. If the key does not exist or contains a value of a wrong type,
set the key to the value of "0" or similar string representation of an integer
before running the function.
The new value of key after the increment. Note that the value is returned as a raw Redis string value.
B. W. Lewis
http://redis.io/commands
## Not run: redisSet('x',charToRaw('5')) # Note the value must be a raw string! redisIncr('x') redisIncrBy('x','3') redisIncrBy('x',3) # also works redisIncrByFloat('x',pi) redisDecr('x') redisDecrBy('x',3) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.