Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Redis setex

Set with expiration time in seconds.

import redis
import time
r = redis.StrictRedis()


r.setex("login", 2, 'foobar') 
print(r.get("login"))   # 'foobar'
time.sleep(1)
print(r.get("login"))   # 'foobar'
time.sleep(1)
print(r.get("login"))   # None