import time
import redis
redis.Redis(host='localhost',port=6379)
conn=redis.Redis()
conn.set('name','westos',3)
print(conn.get('name'))
print('等待3s...')
time.sleep(3)
print(conn.get('name'))
pool = redis.ConnectionPool(host='localhost',port=6379)
conn = redis.Redis(connection_pool=pool)
conn.set('name','粉条',4) #4代表的是失效时间 单位为s
print('等待3s....')
time.sleep(3)
print(conn.get('name'))