incrementer


Nameincrementer JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
Summary分布式主键生成器,支持多机器|多进程|多线程并发生成。
upload_time2024-07-28 23:49:02
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords incrementer increment
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 项目描述

分布式主键生成器,支持多机器\|多进程\|多线程并发生成。

# 作者

江南雨上

[主页](https://lcctoor.com/index.html) \| [Github](https://github.com/lcctoor) \| [PyPi](https://pypi.org/user/lcctoor) \| [微信](https://lcctoor.com/cdn/WeChatQRC.jpg) \| [邮箱](mailto:lcctoor@outlook.com) \| [捐赠](https://lcctoor.com/cdn/DonationQRC-0rmb.jpg)

# Bug提交、功能提议

你可以通过 [Github-Issues](https://github.com/lcctoor/arts/issues)、[微信](https://lcctoor.com/cdn/WeChatQRC.jpg) 与我联系。

# 安装

```
pip install incrementer
```

# 教程

本文将以简洁的方式向你介绍核心知识,而不会让你被繁琐的术语所淹没。

## 导入

```python
from incrementer import Incrementer
```

## 创建生成器

```python
inc = Incrementer()
```

## 创建自增主键

```python
inc.get_incpk()  # >>> '1_1'
inc.get_incpk()  # >>> '1_2'
inc.get_incpk()  # >>> '1_3'
```

`_` 左边的 `1` 表示线程编码。

如果是在单线程情况下使用,可以调用 `get_simple_incpk` 方法:

```python
inc.get_simple_incpk()  # >>> '1'
inc.get_simple_incpk()  # >>> '2'
inc.get_simple_incpk()  # >>> '3'
```

get_incpk 同时适用于单线程和多线程情况下,而 get_simple_incpk 仅适用于单线程情况下。

## 获取编码后的时间戳

```python
inc.get_encoded_time()  # >>> 'lwdnayli'
```

## 获取编码后的进程ID

```python
inc.encoded_pid  # >>> '30g'
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "incrementer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "incrementer, increment",
    "author": null,
    "author_email": "\u6c5f\u5357\u96e8\u4e0a <lcctoor@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/a5/d8/e452231d492852ab71e0305c0e894333d4a88da1779e66a9c86a9a2414a3/incrementer-1.0.2.tar.gz",
    "platform": null,
    "description": "# \u9879\u76ee\u63cf\u8ff0\n\n\u5206\u5e03\u5f0f\u4e3b\u952e\u751f\u6210\u5668\uff0c\u652f\u6301\u591a\u673a\u5668\\|\u591a\u8fdb\u7a0b\\|\u591a\u7ebf\u7a0b\u5e76\u53d1\u751f\u6210\u3002\n\n# \u4f5c\u8005\n\n\u6c5f\u5357\u96e8\u4e0a\n\n[\u4e3b\u9875](https://lcctoor.com/index.html) \\| [Github](https://github.com/lcctoor) \\| [PyPi](https://pypi.org/user/lcctoor) \\| [\u5fae\u4fe1](https://lcctoor.com/cdn/WeChatQRC.jpg) \\| [\u90ae\u7bb1](mailto:lcctoor@outlook.com) \\| [\u6350\u8d60](https://lcctoor.com/cdn/DonationQRC-0rmb.jpg)\n\n# Bug\u63d0\u4ea4\u3001\u529f\u80fd\u63d0\u8bae\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7 [Github-Issues](https://github.com/lcctoor/arts/issues)\u3001[\u5fae\u4fe1](https://lcctoor.com/cdn/WeChatQRC.jpg) \u4e0e\u6211\u8054\u7cfb\u3002\n\n# \u5b89\u88c5\n\n```\npip install incrementer\n```\n\n# \u6559\u7a0b\n\n\u672c\u6587\u5c06\u4ee5\u7b80\u6d01\u7684\u65b9\u5f0f\u5411\u4f60\u4ecb\u7ecd\u6838\u5fc3\u77e5\u8bc6\uff0c\u800c\u4e0d\u4f1a\u8ba9\u4f60\u88ab\u7e41\u7410\u7684\u672f\u8bed\u6240\u6df9\u6ca1\u3002\n\n## \u5bfc\u5165\n\n```python\nfrom incrementer import Incrementer\n```\n\n## \u521b\u5efa\u751f\u6210\u5668\n\n```python\ninc = Incrementer()\n```\n\n## \u521b\u5efa\u81ea\u589e\u4e3b\u952e\n\n```python\ninc.get_incpk()  # >>> '1_1'\ninc.get_incpk()  # >>> '1_2'\ninc.get_incpk()  # >>> '1_3'\n```\n\n`_` \u5de6\u8fb9\u7684 `1` \u8868\u793a\u7ebf\u7a0b\u7f16\u7801\u3002\n\n\u5982\u679c\u662f\u5728\u5355\u7ebf\u7a0b\u60c5\u51b5\u4e0b\u4f7f\u7528\uff0c\u53ef\u4ee5\u8c03\u7528 `get_simple_incpk` \u65b9\u6cd5\uff1a\n\n```python\ninc.get_simple_incpk()  # >>> '1'\ninc.get_simple_incpk()  # >>> '2'\ninc.get_simple_incpk()  # >>> '3'\n```\n\nget_incpk \u540c\u65f6\u9002\u7528\u4e8e\u5355\u7ebf\u7a0b\u548c\u591a\u7ebf\u7a0b\u60c5\u51b5\u4e0b\uff0c\u800c get_simple_incpk \u4ec5\u9002\u7528\u4e8e\u5355\u7ebf\u7a0b\u60c5\u51b5\u4e0b\u3002\n\n## \u83b7\u53d6\u7f16\u7801\u540e\u7684\u65f6\u95f4\u6233\n\n```python\ninc.get_encoded_time()  # >>> 'lwdnayli'\n```\n\n## \u83b7\u53d6\u7f16\u7801\u540e\u7684\u8fdb\u7a0bID\n\n```python\ninc.encoded_pid  # >>> '30g'\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u5206\u5e03\u5f0f\u4e3b\u952e\u751f\u6210\u5668\uff0c\u652f\u6301\u591a\u673a\u5668|\u591a\u8fdb\u7a0b|\u591a\u7ebf\u7a0b\u5e76\u53d1\u751f\u6210\u3002",
    "version": "1.0.2",
    "project_urls": {
        "Source": "https://github.com/lcctoor/arts/tree/main/arts/incrementer"
    },
    "split_keywords": [
        "incrementer",
        " increment"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4381629add2b1ef256acbef4d3bb49e1c9d0e83a6a9824fcb49f03d17e983923",
                "md5": "3e7c3a9ea4e8305a1c6053d164f40d01",
                "sha256": "d04b908037b8a12bf2d8c9df5ea40c9408f8f5734c23f3df40bccb0c21c18e3e"
            },
            "downloads": -1,
            "filename": "incrementer-1.0.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e7c3a9ea4e8305a1c6053d164f40d01",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5979,
            "upload_time": "2024-07-28T23:48:59",
            "upload_time_iso_8601": "2024-07-28T23:48:59.174642Z",
            "url": "https://files.pythonhosted.org/packages/43/81/629add2b1ef256acbef4d3bb49e1c9d0e83a6a9824fcb49f03d17e983923/incrementer-1.0.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a5d8e452231d492852ab71e0305c0e894333d4a88da1779e66a9c86a9a2414a3",
                "md5": "aeb1ebbd3b2f25edf77c36bf0081875c",
                "sha256": "6de0d94539b224fb8c463f2fcbb8cae5ace75b6147c0e9bea53a4db141ceb577"
            },
            "downloads": -1,
            "filename": "incrementer-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "aeb1ebbd3b2f25edf77c36bf0081875c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6468,
            "upload_time": "2024-07-28T23:49:02",
            "upload_time_iso_8601": "2024-07-28T23:49:02.048856Z",
            "url": "https://files.pythonhosted.org/packages/a5/d8/e452231d492852ab71e0305c0e894333d4a88da1779e66a9c86a9a2414a3/incrementer-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-28 23:49:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lcctoor",
    "github_project": "arts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "incrementer"
}
        
Elapsed time: 1.27109s