Module Hub Beta

CHECKAND

key value [XX] [arg1] [...]

Checks a String ‘key’ for ‘value’ equality and executes a command on it. Command can be any of the following Redis String commands: APPEND, DECR[BY] GETSET, INCR[BY], INCRBYFLOAT, PSETEX, SET[EX|NX]. The XX flag means that the key must exist for the equality to be evaluated.

Note: the key shouldn’t be repeated for the executed command.

Return Value

Null if not equal or for non existing key when the XX flag is used. On success, the reply depends on the actual command executed.

Examples

redis> SET mykey “Hello World”
OK
redis> CHECKAND mykey “Hello World” SET mykey “Hello Redis Modules”
OK
redis> GET mykey
“Hello Redis Modules”

© 2017 Redis Labs, Inc. All rights reserved.