RedisServer-Queue 0.0.1__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.1
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
@@ -11,3 +11,28 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
+
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`
@@ -19,7 +19,20 @@ if os.path.basename(__file__) in ['run.py', 'main.py', '__main__.py']:
19
19
  else:
20
20
  sys.path.append(os.path.abspath(__file__))
21
21
 
22
- r = redis.Redis(host='localhost', port=6379, db=0)
22
+ r = redis.Redis
23
+
24
+
25
+ def init(redis_obj=None):
26
+ '''
27
+ 初始化redis
28
+ :param redis_obj:
29
+ :return:
30
+ '''
31
+ global r
32
+ if redis_obj:
33
+ r = redis_obj
34
+ else:
35
+ r = r(host='localhost', port=6379, db=0)
23
36
 
24
37
 
25
38
  class RedisQueue:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RedisServer-Queue
3
- Version: 0.0.1
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
@@ -11,3 +11,28 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
+
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`
@@ -1,8 +1,9 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- RedisServer/RedisServer.py
4
+ RedisServer_Queue/RedisServer.py
5
5
  RedisServer_Queue.egg-info/PKG-INFO
6
6
  RedisServer_Queue.egg-info/SOURCES.txt
7
7
  RedisServer_Queue.egg-info/dependency_links.txt
8
- RedisServer_Queue.egg-info/top_level.txt
8
+ RedisServer_Queue.egg-info/top_level.txt
9
+ test/test.py
@@ -0,0 +1 @@
1
+ RedisServer_Queue
@@ -3,9 +3,9 @@ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "RedisServer-Queue"
6
- version = "0.0.1"
6
+ version = "0.0.4"
7
7
  authors = [
8
- { name="NelsonLongXiang", email="1169207670@qq.com" },
8
+ { name = "NelsonLongXiang", email = "1169207670@qq.com" },
9
9
  ]
10
10
  description = "RedisServer-Queue is a simple redis server"
11
11
  readme = "README.md"
@@ -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()
File without changes