>From time to time, we need to give something (like requests, objects, etc.) unique numbers. Timestamp and random number cannot ensure uniqueness, UUID and generating IDs with Redis are slow. Therefore, I created WUID, an extremely fast unique number generator.
WUID is 10-135 times faster than UUID and 4600 times faster than generating unique numbers with Redis. It generates unique 64-bit integers in sequence. The high 24 bits are loaded from a data store. By now, Redis, MySQL, and MongoDB are supported. *Benchmarks* BenchmarkWUID 100000000 10.3 ns/op 0 B/op 0 allocs/op BenchmarkRand 50000000 24.6 ns/op 0 B/op 0 allocs/op BenchmarkTimestamp 100000000 12.3 ns/op 0 B/op 0 allocs/op BenchmarkUUID_V1 20000000 107 ns/op 0 B/op 0 allocs/op BenchmarkUUID_V2 20000000 106 ns/op 0 B/op 0 allocs/op BenchmarkUUID_V3 5000000 359 ns/op 144 B/op 4 allocs/op BenchmarkUUID_V4 1000000 1376 ns/op 16 B/op 1 allocs/op BenchmarkUUID_V5 3000000 424 ns/op 176 B/op 4 allocs/op BenchmarkRedis 30000 46501 ns/op 176 B/op 5 allocs/op BenchmarkSnowflake 5000000 244 ns/op 0 B/op 0 allocs/op *Features* - Extremely fast - Thread-safe - Being unique within a data center - Being unique across time - Being unique globally if all data centers share the same data store, or they use different section IDs - Being capable of generating 100M unique numbers in a single second - Auto-renew when the low 40 bits are about to run out If you are interested in the project, take a look at https://github.com/edwingeng/wuid -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.