Database Management Redis Subjective
Oct 05, 2025

Explain Redis data types with practical examples.

Detailed Explanation
Redis provides 5 core data types: • Strings (most basic):** SET user:1000:name "Alice" GET user:1000:name INCR user:1000:login_count SETEX temp:token 300 "abc123" # expires in 5 min • Lists (ordered collections):** LPUSH notifications "New message" RPUSH notifications "System update" LRANGE notifications 0 -1 # get all LTRIM notifications 0 99 # keep only 100 items • Sets (unique values):** SADD user:tags "redis" "database" "cache" SISMEMBER user:tags "redis" # check membership SINTER user1:tags user2:tags # common tags • Hashes (field-value pairs):** HSET user:1000 name "Alice" email "alice@example.com" age 30 HGET user:1000 name HINCRBY user:1000 age 1 # increment age • Sorted Sets (scored members):** ZADD leaderboard 1500 "player1" 1200 "player2" ZREVRANGE leaderboard 0 9 WITHSCORES # top 10
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback