12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env python
- # --coding:utf-8--
- import redis
- import os ,sys ,time
- def redis_scan():
- try:
- redisconn = redis.Redis(host='r-bp1lsmidgnw4w7n1pi.redis.rds.aliyuncs.com', password="Wqsd@2019", port=6379,
- db=0)
- except Exception as e:
- print("connect redis error")
- sys.exit(1)
- cursor = 1
- isNoe = True
- file = open('rediskey', 'a+')
- while cursor != 0:
- if isNoe:
- cursor = 0
- isNoe = False
- key = redisconn.scan(cursor, count=10000) #每次拿2000个key
- time.sleep(0.05)
- if len(key[1]) == 0:
- print("key scan finish")
- else:
- for n in key[1]:
- n = bytes.decode(n)
- # MESSAGE_MERGE_LIST_IDS
- # MESSAGE_MERGE_LIST_COUNT
- if n[:23] == "MESSAGE_MERGE_LIST_SORT":
- # MESSAGE_MERGE_LIST_SORT
- redisconn.expire(n,2592000)
- print(n)
- cursor = key[0]
- file.close()
- redis_scan()
|