Skip to content
DEL, EXISTS, KEYS & TYPE
step 1/3

Reading — step 1 of 3

Key Management

~1 min readAdvanced Features

DEL, EXISTS, KEYS & TYPE

These commands work on keys regardless of their data type.

Commands

  • DEL key [key ...] — delete keys, return count deleted
  • EXISTS key [key ...] — return count of keys that exist
  • KEYS * — return all keys as array (we only support * wildcard)
  • TYPE key — return type: +string, +list, +hash, +set, +zset, or +none
  • RENAME key newkey — rename key, error if source doesn't exist

DEL Is Universal

DEL removes a key regardless of its type — string, list, hash, set, or sorted set. It cleans up all associated data.

TYPE Returns Simple Strings

Note: TYPE returns a simple string (+string\r\n), not a bulk string. This is one of the few Redis commands with this behavior.

EXISTS Counting

EXISTS a a b returns :3 if all exist — it counts each argument, even duplicates. This is useful for checking multiple keys at once.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…