Introduction
TTL-based expiry helps automatically remove data after a set time, keeping your database clean and saving space.
EXPIRE key seconds TTL key PERSIST key
SET mykey "hello" EXPIRE mykey 10
TTL mykey
PERSIST mykey
SET session_token "abc123" EXPIRE session_token 5 TTL session_token PERSIST session_token TTL session_token
EXPIRE key 60 do?session?SET temp 100EXPIRE temp 10TTL tempSET user123 "data"EXPIRE user123 30PERSIST user123TTL user123cache_item with a value and ensure it expires exactly after 5 minutes. Which sequence of commands correctly achieves this and verifies the expiry?Pass the test and this pattern moves unknown