Generates Twitter-like Snowflake ids in Java - GitHub
文章推薦指數: 80 %
Generates Twitter-like Snowflake ids. In short, this is an id scheme to generate unique 64 bit ids which are roughly sortable across ...
Skiptocontent
{{message}}
phxql
/
snowflake-id
Public
Notifications
Fork
1
Star
13
GeneratesTwitter-likeSnowflakeidsinJava
License
LGPL-3.0license
13
stars
1
fork
Star
Notifications
Code
Issues
0
Pullrequests
0
Actions
Projects
0
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Actions
Projects
Wiki
Security
Insights
Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository.
main
Branches
Tags
Couldnotloadbranches
Nothingtoshow
{{refName}}
default
Couldnotloadtags
Nothingtoshow
{{refName}}
default
1
branch
1
tag
Code
Latestcommit
Gitstats
21
commits
Files
Permalink
Failedtoloadlatestcommitinformation.
Type
Name
Latestcommitmessage
Committime
.mvn/wrapper
src
.editorconfig
.gitignore
CHANGELOG.md
LICENSE
README.md
mvnw
mvnw.cmd
pom.xml
Viewcode
SnowflakeId
Howtouse
Maven
Simpleexample
Moreconfigurationoptions
Calculatemaximumtimestamps,generators,sequenceidsandwraparounddates
Defaultsettings
Changelog?
License
README.md
SnowflakeId
GeneratesTwitter-likeSnowflakeids.
Inshort,thisisanidschemetogenerateunique64bitidswhichareroughlysortableacrossmultiplesystemswithout
acentralinstance.Seethisblogpostformoredetails.
ThisprojectwasheavilyinspiredbyIdGenforC#,there'sagreatHowitworksinthereadme,too.
ThealgorithmisimplementedinplainJavawithoutanydependencies.AllyouneedisatleastJava11.
Suchgeneratedidinbinarylookslikethis(thisis4425020822061056indecimal):
0000000000001111101110001000100001110010001110010000000000000000
||||
||Timestamp(16880114830)||Sequence(0)
||
|Signbit(always0)|Generatorid(1)
Thestructureusedforthisis45bitsforthetimestamp,2forthegeneratorandtheremaining16forthesequence.Thisstructurecanbechangedeasily,seebelowforthecode.
Theidsreallyuseonly63bitsofthe64availabletocircumventproblemswithunsignedlongs.Thegeneratedvaluesarealwayspositive.
Idsfromthesamegeneratoraremonotonicallyincreasing.
Howtouse
Maven
延伸文章資訊
- 1Snowflake ID - Wikipedia
- 2RobThree/IdGen: Twitter Snowflake-alike ID generator for .Net
Twitter Snowflake-alike ID generator for .Net. Contribute to RobThree/IdGen development by creati...
- 3godruoyi/go-snowflake: An Lock Free ID Generator ... - GitHub
An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced). - GitHub -...
- 4bwmarrin/snowflake: A simple to use Go (golang ... - GitHub
A very simple Twitter snowflake generator. · Methods to parse existing snowflake IDs. · Methods t...
- 5Twitter's Snowflake: A distributed time-based unique ID ...
Twitter's Snowflake: A distributed time-based unique ID generator - GitHub - jtejido/snowflake: T...