Back to results for “Expiration & Eviction”
Redis › Redis CLI & Basic Commands

What do the basic SET, GET, and DEL commands do in Redis?

Beginner

Answer

SET stores a value under a specified key, GET retrieves the current value stored under a specified key, and DEL removes one or more keys entirely from Redis, together forming the fundamental building blocks for storing, retrieving, and removing simple data.
SET username 'alice'
GET username
DEL username
Real-world example A simple caching layer uses SET to store a computed result, GET to quickly retrieve it on subsequent requests, and DEL to remove it once it is no longer needed or has become outdated.

Common follow-ups: What does GET return if the requested key does not exist?;Can DEL remove multiple keys in a single command call?