Advertisement
Guest User

Untitled

a guest
May 24th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #!/bin/env python
  2.  
  3. import redis
  4.  
  5.  
  6. REDIS_HOST="localhost"
  7. REDIS_PORT = 6389
  8.  
  9.  
  10. class RedisClient(object):
  11. conn_pool = dict()
  12. for redis_db in xrange(16):
  13. conn_pool[redis_db] = redis.connection.BlockingConnectionPool(
  14. host=REDIS_HOST, port=REDIS_PORT,
  15. db=redis_db, timeout=60)
  16.  
  17. @classmethod
  18. def get(cls, db):
  19. return redis.client.Redis(connection_pool=cls.conn_pool[db])
  20.  
  21.  
  22. def main():
  23. redis_oj = RedisClient().get(0)
  24.  
  25. index = 0
  26. while True:
  27. # print index
  28. ret = redis_oj.scan(index)
  29. index = ret[0]
  30. for k in ret[1]:
  31. if k.endswith("-CANCEL") or k.endswith("-COMPLETED") or k.endswith("-PENDING"):
  32. print k
  33. redis_oj.delete(k)
  34. if index == 0:
  35. break
  36.  
  37.  
  38. if __name__ == "__main__":
  39. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement