diff --git a/keygen/README.md b/keygen/README.md index adf3273..49e36b1 100644 --- a/keygen/README.md +++ b/keygen/README.md @@ -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. diff --git a/keygen/README.zh-CN.md b/keygen/README.zh-CN.md index 4a3315b..92c4a36 100644 --- a/keygen/README.zh-CN.md +++ b/keygen/README.zh-CN.md @@ -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 许可证。