Skip to content

Commit

Permalink
add documents for Keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperphoton committed Jan 17, 2022
1 parent d343d26 commit 7d265c6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
25 changes: 23 additions & 2 deletions keygen/README.md
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.
25 changes: 23 additions & 2 deletions keygen/README.zh-CN.md
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 许可证。

0 comments on commit 7d265c6

Please sign in to comment.