Home

Awesome

SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier

GitHub tag License

SCRU64 ID offers compact, time-ordered unique identifiers generated by distributed nodes. SCRU64 has the following features:

import "os"
import "fmt"
import "github.com/scru64/go-scru64"

// pass node ID through environment variable
os.Setenv("SCRU64_NODE_SPEC", "42/8")

// generate a new identifier object
x := scru64.New()
fmt.Println(x)       // e.g., "0u2r85hm2pt3"
fmt.Println(x.Num()) // as a 64-bit unsigned integer

// generate a textual representation directly
fmt.Println(scru64.NewString()) // e.g., "0u2r85hm2pt4"

See SCRU64 Specification for details.

SCRU64's uniqueness is realm-specific, i.e., dependent on the centralized assignment of node ID to each generator. If you need decentralized, globally unique time-ordered identifiers, consider SCRU128.

License

Licensed under the Apache License, Version 2.0.

See also