redis delete 1

redis delete

redis> SET key1 "Hello"
"OK"
redis> SET key2 "World"
"OK"
redis> DEL key1 key2 key3
(integer) 2
redis>

Here is what the above code is Doing:
1. We’re connecting to Redis on the localhost (127.0.0.1) and port 6379.
2. We’re setting the key1 value to “Hello”.
3. We’re setting the key2 value to “World”.
4. We’re deleting the key1 and key2 keys.
5. We’re deleting the key3 key, but since it doesn’t exist, it’s not deleted.
6. We’re printing the number of keys that were deleted.

Similar Posts