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