#!/usr/bin/python
#!coding:utf-8

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)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-09-27
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
猜你喜欢
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2021-05-30
  • 2021-06-18
相关资源
相似解决方案