Install Redis, use redis-cli, and work with all five core data types.
Most developers think of Redis as a cache. It is one, but it's also much more. Redis keeps all data in memory (fast) and persists to disk (durable). It has five data structures that solve specific problems elegantly.
# Mac: brew install redis
# Linux: sudo apt install redis
redis-server &
redis-cliSET name 'Alice'
GET name
SET counter 0
INCR counter # atomic increment → 1
INCRBY counter 5 # → 6
DECR counter # → 5
SET token 'abc123' EX 3600 # expires in 1 hour
TTL token # time remaining (seconds)
PERSIST token # remove expirationHSET user:1 name Alice email [email protected] age 28
HGET user:1 name
HGETALL user:1
HMSET user:2 name Bob email [email protected]
HDEL user:1 age
HEXISTS user:1 email# Lists (ordered, allows duplicates)
LPUSH mylist 'a' 'b' 'c' # push to head
RPUSH mylist 'd' # push to tail
LRANGE mylist 0 -1 # get all
LPOP mylist # pop from head
# Sets (unordered, unique members)
SADD tags python javascript rust
SMEMBERS tags
SISMEMBER tags python # 1 if member
SCARD tags # count
# Sorted Sets (score + member)
ZADD leaderboard 100 alice 85 bob 92 carol
ZRANGE leaderboard 0 -1 WITHSCORES
ZRANK leaderboard alice # 0-based rank
ZREVRANK leaderboard alice # rank from top