Video in progress

List the main data types in Redis and give one example for each.

What it holds / Example — String: text, a number or bytes / SET user:1:name "Ali", INCR views; List: an ordered list / the last 10 notifications; Hash: field → value / HSET user:1 name Ali age 25; Set: a collection without duplicates / users who liked an article; Sorted Set: a set ordered by score / a game…

📖 Answer

Type What it holds Example
String text, a number or bytes SET user:1:name "Ali", INCR views
List an ordered list the last 10 notifications
Hash field → value HSET user:1 name Ali age 25
Set a collection without duplicates users who liked an article
Sorted Set a set ordered by score a game leaderboard
Stream an append-only log order events

In interviews they often ask, "why not just store everything as a JSON string?" The answer: once you pick a type, Redis performs the operation on the server side. For example, with a Hash you increment a single field with HINCRBY, with no need to read the whole object, change it and write it back.