Liking cljdoc? Tell your friends :D

com.vadelabs.uid.flake.interface

High-performance time-ordered unique identifiers.

Flakes are 192-bit identifiers designed for distributed systems that need:

  • Guaranteed ordering based on creation time
  • High entropy for uniqueness
  • Compact string representation
  • Fast generation (sub-50ns target)

Structure

  • 64 bits: High-precision timestamp (nanosecond resolution)
  • 128 bits: Cryptographically random data

Key Properties

  • Monotonic: Later-generated flakes sort after earlier ones
  • Order-preserving: String representations maintain sort order
  • URL-safe: Uses web-safe Base64-variant encoding
  • Collision-resistant: 128 bits of entropy per timestamp

Performance

Optimized for high-throughput scenarios with thread-local randomization and efficient encoding algorithms.

High-performance time-ordered unique identifiers.

Flakes are 192-bit identifiers designed for distributed systems that need:
- Guaranteed ordering based on creation time
- High entropy for uniqueness
- Compact string representation
- Fast generation (sub-50ns target)

## Structure
- 64 bits: High-precision timestamp (nanosecond resolution)
- 128 bits: Cryptographically random data

## Key Properties
- **Monotonic**: Later-generated flakes sort after earlier ones
- **Order-preserving**: String representations maintain sort order
- **URL-safe**: Uses web-safe Base64-variant encoding
- **Collision-resistant**: 128 bits of entropy per timestamp

## Performance
Optimized for high-throughput scenarios with thread-local randomization
and efficient encoding algorithms.
raw docstring

flakeclj

(flake)

Generates a new time-ordered unique identifier.

Returns a 192-bit identifier that is guaranteed to be larger than any previously generated Flake in the same thread.

Generates a new time-ordered unique identifier.

Returns a 192-bit identifier that is guaranteed to be larger than any
previously generated Flake in the same thread.
sourceraw docstring

flake-bytesclj

(flake-bytes f)

Get the byte array representation of a flake

Get the byte array representation of a flake
sourceraw docstring

flake-hexclj

(flake-hex f)

Returns hexadecimal representation of a Flake.

Returns a 48-character lowercase hexadecimal string.

Returns hexadecimal representation of a Flake.

Returns a 48-character lowercase hexadecimal string.
sourceraw docstring

flake-timeclj

(flake-time f)

Extracts the timestamp component in nanoseconds.

Returns the nanosecond timestamp indicating when the Flake was created.

Extracts the timestamp component in nanoseconds.

Returns the nanosecond timestamp indicating when the Flake was created.
sourceraw docstring

flake?clj

(flake? x)

Checks if the given value is a Flake instance.

Checks if the given value is a Flake instance.
sourceraw docstring

from-stringclj

(from-string s)

Parses a Flake from its string representation.

Returns a Flake instance or nil if the input is invalid.

Parses a Flake from its string representation.

Returns a Flake instance or nil if the input is invalid.
sourceraw docstring

make-flakeclj

(make-flake byte-data)
(make-flake timestamp-nanos random-high random-low)

Create a flake with specific timestamp and random components (for testing)

Create a flake with specific timestamp and random components (for testing)
sourceraw docstring

read-methodclj

(read-method flake-str)

Reader method for #flake/flake tagged literals.

Reader method for #flake/flake tagged literals.
sourceraw docstring

snowflakeclj

(snowflake)

Generates a new Flake as a URL-safe string.

Returns a 32-character string that preserves the monotonic ordering of the underlying Flake values.

Generates a new Flake as a URL-safe string.

Returns a 32-character string that preserves the monotonic ordering
of the underlying Flake values.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close