increment 1.2__tar.gz → 1.3.1__tar.gz
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.
- {increment-1.2 → increment-1.3.1}/PKG-INFO +9 -10
- {increment-1.2 → increment-1.3.1}/README.md +5 -8
- increment-1.3.1/increment.py +1 -0
- {increment-1.2 → increment-1.3.1}/pyproject.toml +4 -4
- increment-1.2/increment/__init__.py +0 -1
- increment-1.2/increment/_increment.py +0 -52
- {increment-1.2 → increment-1.3.1}/LICENSE +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: increment
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.3.1
|
|
4
|
+
Summary: 分布式主键生成器,支持多机器|多进程|多线程并发生成
|
|
5
5
|
Keywords: increment
|
|
6
6
|
Author-email: 许灿标 <lcctoor@outlook.com>
|
|
7
7
|
Requires-Python: >=3.7
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
-
|
|
10
|
+
Requires-Dist: lccpy >=1.3
|
|
11
|
+
Project-URL: HomePage, https://github.com/lcctoor/lccpy/tree/main/packages/increment#readme
|
|
11
12
|
|
|
12
13
|
# 项目描述
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
分布式主键生成器,支持多机器|多进程|多线程并发生成。
|
|
15
16
|
|
|
16
17
|
# 安装
|
|
17
18
|
|
|
@@ -65,20 +66,17 @@ inc.pk1()
|
|
|
65
66
|
inc.pk2()
|
|
66
67
|
# >>> 'lg8657cj_gsdo_258_0_3'
|
|
67
68
|
|
|
68
|
-
inc.pk2()
|
|
69
|
-
# >>> 'lg8657cj_gsdo_258_0_4'
|
|
70
|
-
|
|
71
69
|
# 'lg8657cj'是当前时间
|
|
72
70
|
```
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
只返回自增主键:
|
|
75
73
|
|
|
76
74
|
```python
|
|
77
75
|
inc.pk3()
|
|
78
|
-
# >>> '
|
|
76
|
+
# >>> '0_4'
|
|
79
77
|
|
|
80
78
|
inc.pk3()
|
|
81
|
-
# >>> '
|
|
79
|
+
# >>> '0_5'
|
|
82
80
|
```
|
|
83
81
|
|
|
84
82
|
# 支持作者1元
|
|
@@ -88,3 +86,4 @@ increment 是一个免费的开源项目,由个人维护。
|
|
|
88
86
|
每个小的贡献,都是构成车轮的一份子,可以帮助保持车轮完美旋转。
|
|
89
87
|
|
|
90
88
|

|
|
89
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 项目描述
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
分布式主键生成器,支持多机器|多进程|多线程并发生成。
|
|
4
4
|
|
|
5
5
|
# 安装
|
|
6
6
|
|
|
@@ -54,20 +54,17 @@ inc.pk1()
|
|
|
54
54
|
inc.pk2()
|
|
55
55
|
# >>> 'lg8657cj_gsdo_258_0_3'
|
|
56
56
|
|
|
57
|
-
inc.pk2()
|
|
58
|
-
# >>> 'lg8657cj_gsdo_258_0_4'
|
|
59
|
-
|
|
60
57
|
# 'lg8657cj'是当前时间
|
|
61
58
|
```
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
只返回自增主键:
|
|
64
61
|
|
|
65
62
|
```python
|
|
66
63
|
inc.pk3()
|
|
67
|
-
# >>> '
|
|
64
|
+
# >>> '0_4'
|
|
68
65
|
|
|
69
66
|
inc.pk3()
|
|
70
|
-
# >>> '
|
|
67
|
+
# >>> '0_5'
|
|
71
68
|
```
|
|
72
69
|
|
|
73
70
|
# 支持作者1元
|
|
@@ -76,4 +73,4 @@ increment 是一个免费的开源项目,由个人维护。
|
|
|
76
73
|
|
|
77
74
|
每个小的贡献,都是构成车轮的一份子,可以帮助保持车轮完美旋转。
|
|
78
75
|
|
|
79
|
-

|
|
76
|
+

|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from lccpy.increment import *
|
|
@@ -4,9 +4,9 @@ build-backend = "flit_core.buildapi"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "increment"
|
|
7
|
-
version = "1.
|
|
8
|
-
description = "
|
|
9
|
-
dependencies = []
|
|
7
|
+
version = "1.3.1"
|
|
8
|
+
description = "分布式主键生成器,支持多机器|多进程|多线程并发生成"
|
|
9
|
+
dependencies = ["lccpy >=1.3"]
|
|
10
10
|
keywords = ["increment"]
|
|
11
11
|
|
|
12
12
|
readme = "README.md"
|
|
@@ -16,4 +16,4 @@ classifiers = ["License :: OSI Approved :: Apache Software License"]
|
|
|
16
16
|
requires-python = ">=3.7"
|
|
17
17
|
|
|
18
18
|
[project.urls]
|
|
19
|
-
HomePage = "https://github.com/lcctoor/lccpy/tree/main/increment"
|
|
19
|
+
HomePage = "https://github.com/lcctoor/lccpy/tree/main/packages/increment#readme"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from ._increment import incrementer
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Copyright [2023] [许灿标]
|
|
3
|
-
license: Apache License, Version 2.0
|
|
4
|
-
email: lcctoor@outlook.com
|
|
5
|
-
'''
|
|
6
|
-
|
|
7
|
-
import time, os
|
|
8
|
-
from collections import deque
|
|
9
|
-
from random import choices
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Characters = ''.join(sorted('0123456789abcdefghijklmnopqrstuvwxyz'))
|
|
13
|
-
LenChars = len(Characters)
|
|
14
|
-
|
|
15
|
-
def EncodeNum(num:int):
|
|
16
|
-
if num > 0:
|
|
17
|
-
rn = deque()
|
|
18
|
-
while num:
|
|
19
|
-
num, i = divmod(num, LenChars)
|
|
20
|
-
rn.appendleft(Characters[i])
|
|
21
|
-
return ''.join(rn)
|
|
22
|
-
return Characters[0]
|
|
23
|
-
|
|
24
|
-
getTid = lambda : EncodeNum(int(time.time() * 1000)) # 一般毫秒后面的数值没有分辨率
|
|
25
|
-
pid = EncodeNum(os.getpid())
|
|
26
|
-
|
|
27
|
-
class incrementer():
|
|
28
|
-
def __init__(self, macid=None, macidSize=4):
|
|
29
|
-
self._threads = []
|
|
30
|
-
self._ContPool = deque()
|
|
31
|
-
self.macid = macid or ''.join(choices(Characters, k=macidSize or 1))
|
|
32
|
-
self._TMP = f"{getTid()}_{self.macid}_{pid}"
|
|
33
|
-
|
|
34
|
-
def _getid(self):
|
|
35
|
-
try:
|
|
36
|
-
cont = self._ContPool.popleft()
|
|
37
|
-
except:
|
|
38
|
-
_ = [] # 随便1个可变对象即可
|
|
39
|
-
self._threads.append(_)
|
|
40
|
-
cont = [EncodeNum(self._threads.index(_)), 0]
|
|
41
|
-
cont[1] += 1
|
|
42
|
-
x, y = cont
|
|
43
|
-
self._ContPool.append(cont)
|
|
44
|
-
return f"{x}_{y}"
|
|
45
|
-
|
|
46
|
-
# 使用创建进程时的时间
|
|
47
|
-
def pk1(self): return f"{self._TMP}_{self._getid()}"
|
|
48
|
-
|
|
49
|
-
# 使用当前时间
|
|
50
|
-
def pk2(self): return f"{getTid()}_{self.macid}_{pid}_{self._getid()}"
|
|
51
|
-
|
|
52
|
-
def pk3(self): return self._getid()
|
|
File without changes
|