{"id":19111271,"url":"https://github.com/callicoder/java-snowflake","last_synced_at":"2025-08-22T06:32:29.974Z","repository":{"id":42699524,"uuid":"157973857","full_name":"callicoder/java-snowflake","owner":"callicoder","description":"Distributed Unique ID Generator in Java inspired by Twitter Snowflake","archived":false,"fork":false,"pushed_at":"2020-01-04T07:02:51.000Z","size":65,"stargazers_count":175,"open_issues_count":3,"forks_count":44,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-11T17:11:44.277Z","etag":null,"topics":["distributed-id-generator","distributed-sequence-generator","id-generator","java","sequence-generator","snowflake","unique-id-generator"],"latest_commit_sha":null,"homepage":"https://www.callicoder.com/distributed-unique-id-sequence-number-generator/","language":"Java","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/callicoder.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-17T10:29:36.000Z","updated_at":"2024-12-04T14:13:50.000Z","dependencies_parsed_at":"2022-09-03T14:42:47.168Z","dependency_job_id":null,"html_url":"https://github.com/callicoder/java-snowflake","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callicoder%2Fjava-snowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callicoder%2Fjava-snowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callicoder%2Fjava-snowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callicoder%2Fjava-snowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/callicoder","download_url":"https://codeload.github.com/callicoder/java-snowflake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230568588,"owners_count":18246378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["distributed-id-generator","distributed-sequence-generator","id-generator","java","sequence-generator","snowflake","unique-id-generator"],"created_at":"2024-11-09T04:27:51.326Z","updated_at":"2024-12-20T10:08:19.946Z","avatar_url":"https://github.com/callicoder.png","language":"Java","readme":"## Java distributed Unique ID generator inspired by Twitter snowflake\n\nYou can read about Twitter snowflake [here](https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html).\n\nThe IDs are 64-bits in size and are generated with the combination of the following:\n\n+ **Epoch timestamp in milliseconds precision** - **41 bits**. The maximum timestamp that can be represented using 41 bits is `2^41 - 1`, or `2199023255551`, which comes out to be `Wednesday, September 7, 2039 3:47:35.551 PM`. That gives us 69 years with respect to a custom epoch..\n+ **Node ID** - **10 bits**. This gives us 1024 nodes/machines.\n+ **Local counter per machine** - **12 bits**. The counter’s max value would be 4095.\n\n## How to use\n\nThe `Snowflake` class should be used as a singleton in your application.\n\n```java\nSnowflake s = new Snowflake(275)\ns.nextId()\n```\n\nRead the blog to understand more:\n\n- [Generating unique IDs in a distributed environment at high scale.](https://www.callicoder.com/distributed-unique-id-sequence-number-generator/)\n","funding_links":[],"categories":["分布式开发"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallicoder%2Fjava-snowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcallicoder%2Fjava-snowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallicoder%2Fjava-snowflake/lists"}