python设置redis过期时间

import time
import redis if __name__ == "__main__":
try:
conn=redis.StrictRedis(host='192.168.80.41')
conn.set('name','蒋乐哥哥')
conn.expire('name',10)
#设置键的过期时间为10s
for item in range(12):
value=conn.get('name')
if value != None:
print(value.decode('utf8'))
else:
print('the key has been deleted...')
break
time.sleep(1)
except Exception as err:
print(err)
上一篇:spring mvc ajax请求


下一篇:spring mvc 详细执行流程