testRedisClient.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: testRedisClient
  5. Description :
  6. Author : JHao
  7. date: 2020/6/23
  8. -------------------------------------------------
  9. Change Activity:
  10. 2020/6/23:
  11. -------------------------------------------------
  12. """
  13. __author__ = 'JHao'
  14. def testRedisClient():
  15. from db.dbClient import DbClient
  16. from helper.proxy import Proxy
  17. uri = "redis://:pwd@127.0.0.1:6379"
  18. db = DbClient(uri)
  19. db.changeTable("use_proxy")
  20. proxy = Proxy.createFromJson(
  21. '{"proxy": "27.38.96.101:9797", "fail_count": 0, "region": "", "type": "",'
  22. ' "source": "freeProxy03", "check_count": 0, "last_status": "", "last_time": ""}')
  23. print("put: ", db.put(proxy))
  24. print("get: ", db.get())
  25. print("exists: ", db.exists("27.38.96.101:9797"))
  26. print("exists: ", db.exists("27.38.96.101:8888"))
  27. print("pop: ", db.pop())
  28. print("getAll: ", db.getAll())
  29. print("getCount", db.getCount())
  30. if __name__ == '__main__':
  31. testRedisClient()