xtn-tools-pro 1.0.1.4.5__py3-none-any.whl → 1.0.1.4.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,8 @@
10
10
  # --------------------------------------------------------------------------------------------------
11
11
  import time
12
12
  import redis
13
+ from redis import Redis
14
+ from typing import Optional
13
15
 
14
16
 
15
17
  class RedisDBPro:
@@ -25,7 +27,7 @@ class RedisDBPro:
25
27
  self._max_connections = max_connections # 同一个redis对象使用的并发数(连接池的最大连接数),超过这个数量会抛出redis.ConnectionError
26
28
  self._kwargs = kwargs
27
29
  # 连接
28
- self.__redis = None
30
+ self.__redis: Optional[Redis] = None
29
31
  self.get_connect()
30
32
 
31
33
  def __del__(self):
@@ -174,6 +176,34 @@ class RedisDBPro:
174
176
  def delete(self, table):
175
177
  return self._redis.delete(table)
176
178
 
179
+ def hset(self, table: str, key=None, value=None, mapping=None):
180
+ """
181
+ 返回值:新增字段的个数(1表示新加;0表示覆盖了已有字段)
182
+ 一次性设置多个字段:使用 mapping 参数(推荐)
183
+ :param table:
184
+ :param key:
185
+ :param value:
186
+ :param mapping:
187
+ :return:
188
+ """
189
+ return self._redis.hset(name=table, key=key, value=value, mapping=mapping)
190
+
191
+ def hget(self,name,key):
192
+ """
193
+ 读单个
194
+ :param name: 表
195
+ :param key: key
196
+ :return:
197
+ """
198
+ return self._redis.hget(name,key)
199
+
200
+ def hgetall(self,name):
201
+ """
202
+ 读全部字段(小 Hash 可用,大 Hash 慎用)
203
+ :param name:
204
+ :return:
205
+ """
206
+ return self._redis.hgetall(name)
177
207
 
178
208
  if __name__ == '__main__':
179
209
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtn-tools-pro
3
- Version: 1.0.1.4.5
3
+ Version: 1.0.1.4.6
4
4
  Summary: xtn 开发工具
5
5
  Author: xtn
6
6
  Author-email: czw011122@gmail.com
@@ -7,7 +7,7 @@ xtn_tools_pro/data/__init__.py,sha256=Cg6fMz1PlSjPa1LUyQtpzvvjvFdxiky_PjxaNFr3wI
7
7
  xtn_tools_pro/data/set_data_pro.py,sha256=Cg6fMz1PlSjPa1LUyQtpzvvjvFdxiky_PjxaNFr3wIo,418
8
8
  xtn_tools_pro/db/MongoDB.py,sha256=CljtA5NnutOPL0j2ClrCE4RXW-9N_306D3PAdRANmuk,5699
9
9
  xtn_tools_pro/db/MysqlDB.py,sha256=SBJrcjbZdxmtTKPGwl57NthPhs4uX8J3P6o_rK01O4k,13373
10
- xtn_tools_pro/db/RedisDB.py,sha256=xi5YcMP2LISASpzyxA2r2c_5GYocMKqBrdZJJtwRZMA,6493
10
+ xtn_tools_pro/db/RedisDB.py,sha256=aFNuG7Ae_3ltTM0ua_SQBGqI5JkecmIlw5gzrzVgMXg,7427
11
11
  xtn_tools_pro/db/__init__.py,sha256=Zg91UWS02TO0Ba_0AY56s0oabRy93xLNFkpIIL_6mMM,416
12
12
  xtn_tools_pro/flask_demo/__init__.py,sha256=2hSMIjKC8-T_9aTJU35DjkwWKa1-ZzMgwfFajs69TWI,418
13
13
  xtn_tools_pro/flask_demo/cli.py,sha256=wBcdWu5uN1QB8begyGHnhSln4IiZJPTFE8CDy0sQGTk,3116
@@ -70,9 +70,9 @@ xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,
70
70
  xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
71
71
  xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
72
72
  xtn_tools_pro/utils/win.py,sha256=D5_58WMKOGe9ZwJuJr2JGAWmVISwMOZUx4t7wXUCviU,3512
73
- xtn_tools_pro-1.0.1.4.5.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- xtn_tools_pro-1.0.1.4.5.dist-info/METADATA,sha256=3GYOF046qBtCVix5x_kFdUVRqEWRUF0gtk9-3c6MaNg,597
75
- xtn_tools_pro-1.0.1.4.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
76
- xtn_tools_pro-1.0.1.4.5.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
77
- xtn_tools_pro-1.0.1.4.5.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
78
- xtn_tools_pro-1.0.1.4.5.dist-info/RECORD,,
73
+ xtn_tools_pro-1.0.1.4.6.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
+ xtn_tools_pro-1.0.1.4.6.dist-info/METADATA,sha256=S5w2yvyH6LHUjR6z8LFJlOu0faZ3VIPaTDsDh936hXs,597
75
+ xtn_tools_pro-1.0.1.4.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
76
+ xtn_tools_pro-1.0.1.4.6.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
77
+ xtn_tools_pro-1.0.1.4.6.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
78
+ xtn_tools_pro-1.0.1.4.6.dist-info/RECORD,,