snowflake algorithm
- 200+ years long time support
- support 1024 processes(machines) at most
- generate 1,000,000 id/s per process
import "github.com/lxzan/snowflake"
func main() {
snowflake.Initialize(1)
println(snowflake.NextID())
var o = Decode(1662468685074268160)
println(fmt.Sprintf("%v",o))
}
// output 1662468685074268160
// &{1548294616 1 0}
- goos: darwin
- goarch: amd64
- pkg: snowflake
- BenchmarkKey-4 100000000 11.0 ns/op
- PASS