Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/env python
- import redis
- REDIS_HOST="localhost"
- REDIS_PORT = 6389
- class RedisClient(object):
- conn_pool = dict()
- for redis_db in xrange(16):
- conn_pool[redis_db] = redis.connection.BlockingConnectionPool(
- host=REDIS_HOST, port=REDIS_PORT,
- db=redis_db, timeout=60)
- @classmethod
- def get(cls, db):
- return redis.client.Redis(connection_pool=cls.conn_pool[db])
- def main():
- redis_oj = RedisClient().get(0)
- index = 0
- while True:
- # print index
- ret = redis_oj.scan(index)
- index = ret[0]
- for k in ret[1]:
- if k.endswith("-CANCEL") or k.endswith("-COMPLETED") or k.endswith("-PENDING"):
- print k
- redis_oj.delete(k)
- if index == 0:
- break
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement