-
Notifications
You must be signed in to change notification settings - Fork 77
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
1 parent
d343d26
commit 7d265c6
Showing
2 changed files
with
46 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
# keygen | ||
# Keygen | ||
|
||
English | [简体中文](./README.zh-CN.md) | ||
|
||
Distributed Primary Key generator. | ||
A Distributed Primary Key generator. | ||
|
||
## Differences with the snowflake algorithm | ||
|
||
Keygen id contains a table index in it's bit sequence, so we can locate the sharding table whitout the sharding key. | ||
For example, use Keygen id, we could use: | ||
|
||
``` | ||
select * from orders where id = 76362673717182593 | ||
``` | ||
|
||
Use snowflake, you should use: | ||
|
||
``` | ||
select * from orders where id = 76362673717182593 and user_id = 100 | ||
``` | ||
|
||
The former is commonly used in CRUD codes so we made this improvement. | ||
|
||
## License | ||
|
||
This project under MIT license. |
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 |
---|---|---|
@@ -1,5 +1,26 @@ | ||
# keygen | ||
# Keygen | ||
|
||
[English](./README.md) | 简体中文 | ||
|
||
分布式主键生成器。 | ||
一个分布式主键生成器。 | ||
|
||
## 与雪花算法的区别 | ||
|
||
Keygen id 在其比特序列中包含了表索引,这样可以在没有分表键的情况下定位分表。 | ||
例如,使用 Keygen id,我们可以: | ||
|
||
``` | ||
select * from orders where id = 76362673717182593 | ||
``` | ||
|
||
使用雪花算法,则需要: | ||
|
||
``` | ||
select * from orders where id = 76362673717182593 and user_id = 100 | ||
``` | ||
|
||
第一种情况在增删改查代码中如此常用,所以我们做了这个改进。 | ||
|
||
## 许可证 | ||
|
||
本项目使用 MIT 许可证。 |