Skip to main content

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

Project description

项目描述

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

作者

江南雨上

主页 | Github | PyPi | 微信 | 邮箱 | 捐赠

Bug提交、功能提议

你可以通过 Github-Issues微信 与我联系。

安装

pip install incrementer

教程

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

导入

from incrementer import Incrementer

创建生成器

inc = Incrementer()

创建自增主键

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

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

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

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

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

获取编码后的时间戳

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

获取编码后的进程ID

inc.encoded_pid  # >>> '30g'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

incrementer-1.0.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

incrementer-1.0.2-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file incrementer-1.0.2.tar.gz.

File metadata

  • Download URL: incrementer-1.0.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for incrementer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6de0d94539b224fb8c463f2fcbb8cae5ace75b6147c0e9bea53a4db141ceb577
MD5 aeb1ebbd3b2f25edf77c36bf0081875c
BLAKE2b-256 a5d8e452231d492852ab71e0305c0e894333d4a88da1779e66a9c86a9a2414a3

See more details on using hashes here.

File details

Details for the file incrementer-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for incrementer-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d04b908037b8a12bf2d8c9df5ea40c9408f8f5734c23f3df40bccb0c21c18e3e
MD5 3e7c3a9ea4e8305a1c6053d164f40d01
BLAKE2b-256 4381629add2b1ef256acbef4d3bb49e1c9d0e83a6a9824fcb49f03d17e983923

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page