- Usage:
-
DELEX key 〈 IFEQ | IFNE 〉 value
- Complexity:
- O(1)
- Since:
- 9.2.0
- ACL Categories:
- @fast, @string, @write
IFEQcomparison-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.IFNEcomparison-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.-
Integer reply:
1ifkeywas deleted. -
Integer reply:
0ifkeywas not deleted because it did not exist or the value did not follow the condition.
Delete key based on condition.
Options
Example
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
RESP2/RESP3 Reply
One of the following: