python操作redis

#!/usr/bin/python
import redis

r = redis.Redis(host='127.0.0.1',password='123',port=6379,db=1)
#print r.get('SGP1234_form_id_oi0yf4t2OCDtxGTJHYLjHIR-d_iw')
for k in r.keys('*SGP1234_form_id*'):
    if r.ttl(k) == -1:
        print k
        #r.delete(k)

删除没有过期时间的key

posted @ 2019-02-12 09:37  行知散人  阅读(196)  评论(0编辑  收藏  举报