Skip to content

lxzan/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snowflake

snowflake algorithm

Feature

  • 200+ years long time support
  • support 1024 processes(machines) at most
  • generate 1,000,000 id/s per process

Example

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}

Benchmark

  • goos: darwin
  • goarch: amd64
  • pkg: snowflake
  • BenchmarkKey-4 100000000 11.0 ns/op
  • PASS

About

snowflake algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages