-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
outline: deep | ||
--- | ||
## useSnowflakeId | ||
|
||
用于生成分布式唯一ID。 | ||
|
||
```python | ||
from usepy import useSnowflakeId | ||
|
||
snowflake = useSnowflakeId() | ||
snowflake.generate_id() # 生成唯一ID | ||
``` | ||
|
||
### 参数 | ||
|
||
- `datacenter_id`:数据中心ID,范围为0-31,可选,默认为1 | ||
- `worker_id`:工作机器ID,范围为0-31,可选,默认为1 | ||
- `sequence`:序列号,范围为0-4095,占12位,可选,默认为0 | ||
|
||
### 返回值 | ||
|
||
- `id`:唯一ID |