Ver Fonte

[update] add explanation for SsdbClient

j_hao há 9 anos atrás
pai
commit
572c66a02d
1 ficheiros alterados com 14 adições e 3 exclusões
  1. 14 3
      DB/SsdbClient.py

+ 14 - 3
DB/SsdbClient.py

@@ -22,14 +22,19 @@ import json
 class SsdbClient(object):
     """
     SSDB client
+
+    SSDB中代理存放的容器为hash:
+        原始代理存放在name为raw_proxy的hash中,key为代理的ip:port,value为None,以后扩展可能会加入代理属性;
+        验证后供flask使用的代理存放在name为useful_proxy_queue的hash中,key为代理的ip:port,value为None,以后扩展可能会加入代理属性;
+
     """
 
     def __init__(self, name, host, port):
         """
         init
-        :param name:
-        :param host:
-        :param port:
+        :param name: hash name
+        :param host: ssdb host
+        :param port: ssdb port
         :return:
         """
         self.name = name
@@ -38,6 +43,8 @@ class SsdbClient(object):
     def get(self):
         """
         get an item
+
+        从useful_proxy_queue随机获取一个可用代理, 使用前需要调用changeTable("useful_proxy_queue")
         :return:
         """
         values = self.__conn.hgetall(name=self.name)
@@ -46,6 +53,8 @@ class SsdbClient(object):
     def put(self, value):
         """
         put an  item
+
+        将代理放入hash, 使用changeTable指定hash name
         :param value:
         :return:
         """
@@ -55,6 +64,8 @@ class SsdbClient(object):
     def pop(self):
         """
         pop an item
+
+        弹出一个代理, 使用changeTable指定hash name
         :return:
         """
         key = self.get()