项目作者: casualjim

项目描述 :
NATS unique identifiers
高级语言: Rust
项目地址: git://github.com/casualjim/rs-nuid.git
创建时间: 2018-04-07T16:30:54Z
项目社区:https://github.com/casualjim/rs-nuid

开源协议:Apache License 2.0

下载


NUID

License Apache 2

A highly performant unique identifier generator.

Installation

In Cargo.toml:

  1. [dependencies]
  2. nuid = "0.5"

Basic Usage

  1. // Utilize the global locked instance
  2. nuid := nuid::next();
  3. // Create an instance, these are not locked.
  4. n := nuid::NUID::new();
  5. nuid = n.next();
  6. // Generate a new crypto/rand seeded prefix.
  7. // Generally not needed, happens automatically.
  8. n.randomize_prefix();

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.