DEL command in redis

DEL key1 key2 ... keyN

Remove the specified keys. If a given key does not exist no operation is performed for this key. The commnad returns the number of keys removed.

TIME COMPLEXITY: O(1)

RETURN VALUE: An integer greater than 0 if one or more keys were removed. 0 if none of the specified keys existed.

Syntax:

DEL key1 key2 .. keyN

Example 1: When the keys are present.

redis:6379> DEL redisKey redisKey1 redisKey2
(integer) 3

Output

3


Example 2: When no keys are present.

redis:6379>  DEL redisKey redisKey1 redisKey2
(integer) 0

Output

0

No comments:

Post a Comment