Archived
1
0
This repository has been archived on 2022-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
ffmpeger/vendor/github.com/nats-io/nuid
2019-05-17 19:06:13 +05:00
..
.gitignore Initial commit. 2019-05-17 19:06:13 +05:00
.travis.yml Initial commit. 2019-05-17 19:06:13 +05:00
GOVERNANCE.md Initial commit. 2019-05-17 19:06:13 +05:00
LICENSE Initial commit. 2019-05-17 19:06:13 +05:00
MAINTAINERS.md Initial commit. 2019-05-17 19:06:13 +05:00
nuid.go Initial commit. 2019-05-17 19:06:13 +05:00
README.md Initial commit. 2019-05-17 19:06:13 +05:00

NUID

License Apache 2 ReportCard Build Status Release GoDoc Coverage Status

A highly performant unique identifier generator.

Installation

Use the go command:

$ go get github.com/nats-io/nuid

Basic Usage


// Utilize the global locked instance
nuid := nuid.Next()

// Create an instance, these are not locked.
n := nuid.New()
nuid = n.Next()

// Generate a new crypto/rand seeded prefix.
// Generally not needed, happens automatically.
n.RandomizePrefix()

Performance

NUID needs to be very fast to generate and be truly unique, all while being entropy pool friendly. NUID uses 12 bytes of crypto generated data (entropy draining), and 10 bytes of pseudo-random sequential data that increments with a pseudo-random increment.

Total length of a NUID string is 22 bytes of base 62 ascii text, so 62^22 or 2707803647802660400290261537185326956544 possibilities.

NUID can generate identifiers as fast as 60ns, or ~16 million per second. There is an associated benchmark you can use to test performance on your own hardware.

License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.