📜  redis delete - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:34:41.755000             🧑  作者: Mango

Redis Delete

redis delete is a command used in the Redis database to delete keys. Keys can be deleted one at a time or in bulk by matching a pattern.

Syntax
redis-cli DEL key [key ...]
Parameters
  • key: The name of the key to delete. You may provide multiple keys separated by spaces.
Examples

To delete a single key:

redis-cli DEL mykey

To delete multiple keys:

redis-cli DEL key1 key2 key3

To delete all keys matching a pattern:

redis-cli DEL user:*
Return Values
  • The command returns the number of keys that were deleted.
Notes
  • Deleting a non-existing key will have no effect.
  • Deleting a key that belongs to a hash, list, or set will delete the entire data structure.
Markdown Code Snippet

redis-cli DEL mykey

redis-cli DEL key1 key2 key3

redis-cli DEL user:*