//Insert
FLUSHDB
HSET movie:101 title "Bold and Beautiful" year 2014 popularity 91
HSET movie:102 title "Furious Code" year 2020 popularity 77
HSET movie:103 title "Neo Nights" year 2019 popularity 84
HSET movie:104 title "Prague Story" year 2023 popularity 69
HSET actor:6384 name "Actor A"
HSET actor:7001 name "Actor B"
SADD movie:101:cast 6384
SADD movie:102:cast 6384
SADD movie:103:cast 6384
SADD movie:104:cast 7001
SADD actor:6384:movies 101 102 103
SADD actor:7001:movies 104
ZINCRBY tags:top:week:2025-37 4 drama
ZINCRBY tags:top:week:2025-37 3 action
ZINCRBY tags:top:week:2025-37 2 romance
ZINCRBY tags:top:week:2025-37 1 database
EXPIRE tags:top:week:2025-37 604800
HGETALL movie:101
HGETALL actor:6384
SMEMBERS movie:101:cast
SMEMBERS actor:6384:movies
ZREVRANGE tags:top:week:2025-37 0 3 WITHSCORES
TTL tags:top:week:2025-37


//Transaction1
MULTI
SADD movie:101:cast 7001
SADD actor:7001:movies 101
EXEC

//Verify (must be true)
SISMEMBER movie:101:cast 7001
SISMEMBER actor:7001:movies 101
//Expected: 1 and 1.

//Transaction2
HGET movie:101 popularity

MULTI
HINCRBY movie:101 popularity
//ERROR

DISCARD

//Verify (must be unchanged)
HGET movie:101 popularity


//Transaction3
//Setup (create wrong type)
SET oops "I am a string"
TYPE oops
//Expected: string.

//Commands
MULTI
INCR tx:ok
LPUSH oops "will_fail"
INCR tx:ok2
EXEC

//Verify (partial success)
GET tx:ok
GET tx:ok2
TYPE oops
GET oops

//Expected:
//tx:ok increased
//tx:ok2 increased
//oops still string and value unchanged
//And EXEC output contains a WRONGTYPE error for the middle command.

//Transaction4
//Terminal A (redis-cli #1)
SISMEMBER movie:101:cast 5556
//Expected: 0

//WATCH and queue the change (do not EXEC yet)
WATCH movie:101:cast
MULTI
SADD movie:101:cast 5556

//Terminal B (redis-cli #2)
//modify the watched key
SADD movie:101:cast 9999

SISMEMBER movie:101:cast 9999
//Expected: 1.

//Terminal A
//Try to commit
EXEC
//EXEC returns: (nil)

//Verify that the transaction did NOT apply
SISMEMBER movie:101:cast 5556
//Expected: 0.

//Optimization
HGET actor:6384 name
HGET actor:6384 birthdate
HGET actor:6384 country

HMGET actor:6384 name birthdate country

//SLOWLOG
CONFIG GET slowlog-log-slower-than
CONFIG GET slowlog-max-len

CONFIG SET slowlog-log-slower-than 0
SLOWLOG RESET

HGETALL movie:101
HMGET movie:101 title popularity
SMEMBERS person:6384:movies
ZRANGE tags:top:week:2025-37 0 2 REV WITHSCORES
TTL tags:top:week:2025-37

SLOWLOG GET 10

CONFIG SET slowlog-log-slower-than 10000