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)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM