RedisServer-Queue 0.0.3__tar.gz → 0.0.4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RedisServer-Queue
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: RedisServer-Queue is a simple redis server
5
5
  Author-email: NelsonLongXiang <1169207670@qq.com>
6
6
  Project-URL: Homepage, https://github.com/NelsonLongxiang/RedisServer
@@ -13,3 +13,26 @@ Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
 
15
15
  RedisServer-Queue is a simple redis server
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install -i https://pypi.org/simple RedisServer-Queue
21
+ ```
22
+
23
+ ```commandline
24
+ pip install --upgrade -i https://pypi.org/simple RedisServer-Queue
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ #### 请参考test目录下test.py文件
30
+
31
+ ## License
32
+
33
+ [MIT](https://choosealicense.com/licenses/mit/)
34
+
35
+ ### 作者联系方式
36
+
37
+ 1. 作者邮箱:`1169207670@qq.com`
38
+ 2. Wechat: `1169207670`
@@ -0,0 +1,24 @@
1
+ RedisServer-Queue is a simple redis server
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ pip install -i https://pypi.org/simple RedisServer-Queue
7
+ ```
8
+
9
+ ```commandline
10
+ pip install --upgrade -i https://pypi.org/simple RedisServer-Queue
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ #### 请参考test目录下test.py文件
16
+
17
+ ## License
18
+
19
+ [MIT](https://choosealicense.com/licenses/mit/)
20
+
21
+ ### 作者联系方式
22
+
23
+ 1. 作者邮箱:`1169207670@qq.com`
24
+ 2. Wechat: `1169207670`
@@ -22,15 +22,15 @@ if os.path.basename(__file__) in ['run.py', 'main.py', '__main__.py']:
22
22
  r = redis.Redis
23
23
 
24
24
 
25
- def init(rids_boj=None):
25
+ def init(redis_obj=None):
26
26
  '''
27
27
  初始化redis
28
- :param rids_boj:
28
+ :param redis_obj:
29
29
  :return:
30
30
  '''
31
31
  global r
32
- if rids_boj:
33
- r = rids_boj
32
+ if redis_obj:
33
+ r = redis_obj
34
34
  else:
35
35
  r = r(host='localhost', port=6379, db=0)
36
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RedisServer-Queue
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: RedisServer-Queue is a simple redis server
5
5
  Author-email: NelsonLongXiang <1169207670@qq.com>
6
6
  Project-URL: Homepage, https://github.com/NelsonLongxiang/RedisServer
@@ -13,3 +13,26 @@ Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
 
15
15
  RedisServer-Queue is a simple redis server
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install -i https://pypi.org/simple RedisServer-Queue
21
+ ```
22
+
23
+ ```commandline
24
+ pip install --upgrade -i https://pypi.org/simple RedisServer-Queue
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ #### 请参考test目录下test.py文件
30
+
31
+ ## License
32
+
33
+ [MIT](https://choosealicense.com/licenses/mit/)
34
+
35
+ ### 作者联系方式
36
+
37
+ 1. 作者邮箱:`1169207670@qq.com`
38
+ 2. Wechat: `1169207670`
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "RedisServer-Queue"
6
- version = "0.0.3"
6
+ version = "0.0.4"
7
7
  authors = [
8
8
  { name = "NelsonLongXiang", email = "1169207670@qq.com" },
9
9
  ]
@@ -0,0 +1,86 @@
1
+ #!/user/bin/env python3
2
+ # -*- coding: UTF-8 -*-
3
+ # @Time : 2024/6/15 下午5:02
4
+ # @Author : 龙翔
5
+ # @File :test.py.py
6
+ # @Software: PyCharm
7
+
8
+ import os
9
+ import sys
10
+
11
+ import redis
12
+
13
+ # 将当前文件夹添加到环境变量
14
+ if os.path.basename(__file__) in ['run.py', 'main.py', '__main__.py']:
15
+ if '.py' in __file__:
16
+ sys.path.append(os.path.abspath(os.path.dirname(__file__)))
17
+ else:
18
+ sys.path.append(os.path.abspath(__file__))
19
+
20
+ # 导入模块
21
+ from RedisServer_Queue import RedisServer
22
+
23
+ # 初始化Redis服务
24
+ # 默认使用本地Redis服务 6379端口 如果您使用的是远程Redis服务 请修改将实例化后的r对象传入RedisServer.init(r)
25
+ # 使用本地Redis服务端口是6379 默认db是0 则不需要传入参数
26
+ '''
27
+ r = redis.Redis(host='localhost', port=6379, db=0)
28
+ '''
29
+ r = redis.Redis(host='localhost', port=6379, db=0)
30
+
31
+ RedisServer.init(redis_obj=r)
32
+
33
+
34
+ def hello_world():
35
+ '''
36
+ get 数据返回类型为bytes类型
37
+ :return:
38
+ '''
39
+ msg_queue = RedisServer.RedisQueue(topic='msg_queue')
40
+ if msg_queue.qsize() == 0:
41
+ msg_queue.put('hello world')
42
+
43
+ print(msg_queue.get())
44
+
45
+
46
+ def ack_test():
47
+ '''
48
+ ack_test
49
+ :return:
50
+ '''
51
+ msg_queue = RedisServer.RedisQueue(topic='msg_queue')
52
+ print("重置数据,初始化时运行,返回值为重置数据量!", msg_queue.re_data())
53
+ msg_queue.put('hello world')
54
+
55
+ class ThreadAck(RedisServer.RedisQueue, RedisServer.RedisMQ):
56
+ def __init__(self, topic):
57
+ RedisServer.RedisQueue.__init__(self, topic)
58
+ RedisServer.RedisMQ.__init__(self)
59
+ self.ch = None
60
+
61
+ def run(self):
62
+ '''count 默认为-1;当count=1时,表示只获取一个数据,当count>1时,表示获取count个数据
63
+ 根据需要自行修改
64
+ '''
65
+ self.start_receive(topic=self.topic, callback=self.callback)
66
+
67
+ def callback(self, ch, body):
68
+ self.ch = ch
69
+ self.work(body)
70
+ print("剩余队列长度:", self.qsize())
71
+
72
+ def work(self, data):
73
+ if data:
74
+ print(data)
75
+ '''
76
+ ack 注释 可以通过re_data()方法重新将数据放入队列
77
+ '''
78
+ self.ch.basic_ack()
79
+
80
+ thread_ack = ThreadAck(topic='msg_queue')
81
+ thread_ack.run()
82
+
83
+
84
+ if __name__ == '__main__':
85
+ # hello_world()
86
+ ack_test()
@@ -1 +0,0 @@
1
- RedisServer-Queue is a simple redis server
@@ -1,19 +0,0 @@
1
- #!/user/bin/env python3
2
- # -*- coding: UTF-8 -*-
3
- # @Time : 2024/6/15 下午5:02
4
- # @Author : 龙翔
5
- # @File :test.py.py
6
- # @Software: PyCharm
7
-
8
- import os
9
- import sys
10
-
11
- # 将当前文件夹添加到环境变量
12
- if os.path.basename(__file__) in ['run.py', 'main.py', '__main__.py']:
13
- if '.py' in __file__:
14
- sys.path.append(os.path.abspath(os.path.dirname(__file__)))
15
- else:
16
- sys.path.append(os.path.abspath(__file__))
17
- from RedisServer_Queue import RedisServer
18
-
19
- RedisServer.init()