{"id":38753433,"url":"https://github.com/inherelab/idgen","last_synced_at":"2026-01-17T11:51:36.916Z","repository":{"id":37930243,"uuid":"324478391","full_name":"inherelab/idgen","owner":"inherelab","description":"Global ID generator base on MySQL","archived":false,"fork":false,"pushed_at":"2023-12-07T11:42:50.000Z","size":317,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T19:08:56.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inherelab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-26T04:05:42.000Z","updated_at":"2023-04-11T15:33:59.000Z","dependencies_parsed_at":"2023-12-07T12:48:58.261Z","dependency_job_id":null,"html_url":"https://github.com/inherelab/idgen","commit_stats":null,"previous_names":["inherelab/genid"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/inherelab/idgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inherelab%2Fidgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inherelab%2Fidgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inherelab%2Fidgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inherelab%2Fidgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inherelab","download_url":"https://codeload.github.com/inherelab/idgen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inherelab%2Fidgen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T11:51:36.821Z","updated_at":"2026-01-17T11:51:36.903Z","avatar_url":"https://github.com/inherelab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GenId\n\nGlobal ID generator base on MySQL\n\n\u003e Inspired the projects [flike/idgo](https://github.com/flike/idgo) \n\n`genId` is a sequential id generator which can generate batch ids through MySQL transcation way. Its features as follows:\n\n- The ID generated by genId is by order.\n- generate batch ids through MySQL transcation way, dose not increase the load of MySQL.\n- When process crashed, admin can restart server, does not worry about generating repetitive ids.\n- GenId talks with clients using redis protocol. developer can connect the server using redis sdk.\n- The server also supports Http protocol to provide services\n\nSomeone knows the resolution of generating id with MySQL:\n\n```\nREPLACE INTO Tickets64 (stub) VALUES ('a');\nSELECT LAST_INSERT_ID();\n```\n\nThe disadvantage of this resolution is that generates one id need query MySQL once. When generating id too quickly, leading MySQL overload. This is why I build this project to generating ids.\n\n## [中文说明](README.zh-CN.md)\n\n\n## 2. The architecture\n\nGenId talks with clients using redis protocol, developer can connect to genid using redis sdk. Every Key will mapped to a table storing in MySQL, and the table only has one row data to record the id.\n\nGenId only supports four commands of redis as follows:\n\n- `SET key value`, set the initial value of id generator.\n- `GET key`, get the value of key.\n- `EXISTS key`, check the key if exist.\n- `DEL key`, delete the key from server.\n- `SELECT index`, just a mock select command, prevent the select command error.\n\n## 3. Install\n\nInstall following these steps:\n\n1. Install Go environment, the version of Go is greater than `1.12`.\n3. `git clone https://github.com/inherelab/genid`\n4. `cd genid`\n5. `go mod tidy`\n7. set the config file.\n8. run genid: `./bin/genid -config=config/config.toml`\n\nSet the config file(`config/config.toml`):\n\n```ini\n# the address of genid server\naddr=\"127.0.0.1:6389\"\n# log_path: /Users/inhere/go/dev \nlog_level=\"debug\"\n\n[db]\nmysql_host=\"127.0.0.1\"\nmysql_port=3306\ndb_name=\"idgen_test\"\nuser=\"root\"\npassword=\"\"\nmax_idle_conns=64\n```\n\n## Quick start\n\nExamples:\n\n```\n# start server\n➜  genid git:(master) ✗ ./bin/genid redis -config=config/config.toml\n\n#start a redis client to connecting genid server, and set/get the key.\n➜  ~  redis-cli -p 6389\nredis 127.0.0.1:6389\u003e get abc\n(integer) 0\nredis 127.0.0.1:6389\u003e set abc 100\nOK\nredis 127.0.0.1:6389\u003e get abc\n(integer) 101\nredis 127.0.0.1:6389\u003e get abc\n(integer) 102\nredis 127.0.0.1:6389\u003e get abc\n(integer) 103\n```\n\n## 4. HA\n\nWhen the server crashed, you can restart `genid` and reset the key by increasing a fixed offset.\n\n## 5. License\n\nMIT \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finherelab%2Fidgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finherelab%2Fidgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finherelab%2Fidgen/lists"}