Skip to content

Commit

Permalink
📃 docs: useSnowflakeId
Browse files Browse the repository at this point in the history
  • Loading branch information
mic1on committed Aug 20, 2023
1 parent 13b253f commit a904ef4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export default withPwa(defineConfig({
text: 'useParser',
link: '/api/parser',
},
{
text: 'useSnowflakeId',
link: '/api/useSnowflakeId',
},
],
},
{
Expand Down
23 changes: 23 additions & 0 deletions docs/api/useSnowflakeId.md
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

0 comments on commit a904ef4

Please sign in to comment.