Skip to main content

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

Project description

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

PyPI License

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

  • 63-bit non-negative integer storable as signed/unsigned 64-bit integer
  • Sortable by generation time (as integer and as text)
  • 12-digit case-insensitive textual representation (Base36)
  • ~38-bit Unix epoch-based timestamp that ensures useful life until year 4261
  • Variable-length node/machine ID and counter fields that share 24 bits
# pass node ID through environment variable
import os

os.environ["SCRU64_NODE_SPEC"] = "42/8"

import scru64

# generate a new identifier object
x = scru64.new_sync()
print(x)  # e.g., "0u2r85hm2pt3"
print(int(x))  # as a 64-bit unsigned integer


# generate a textual representation directly
print(scru64.new_string_sync())  # 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scru64-1.0.1.tar.gz (11.8 kB view hashes)

Uploaded Source

Built Distribution

scru64-1.0.1-py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page