Delete a key conditionally based on its value.
DELEX key
<IFEQ |
IFNE> value
Delete key based on condition.
IFEQ comparison-value – Delete the key only if
the comparison value matches key’s existing value. Error is returned if
provided key or value is not string.IFNE comparison-value – Delete the key only if
the comparison value does not matches key’s existing value. Error is
returned if provided key or value is not string.One of the following:
1 if key was deleted.0 if key was not deleted because
it did not exist or the value did not follow the condition.O(1)
@fast @string @write
Delete the key if given value is equal to existing
value.
127.0.0.1:6379> SET x 1
OK
127.0.0.1:6379> DELEX x IFEQ 1
(integer) 1
Delete the key if given value is not equal to existing
value.
127.0.0.1:6379> SET x 1
OK
127.0.0.1:6379> DELEX x IFNE 2
(integer) 1
APPEND, DECR, DECRBY, DELIFEQ, GET, GETDEL, GETEX, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, INCREX, LCS, MGET, MSET, MSETEX, MSETNX, PSETEX, SET, SETEX, SETNX, SETRANGE, STRLEN, SUBSTR.