High-performance time-ordered unique identifiers.
Flakes are 192-bit identifiers designed for distributed systems that need:
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.
(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.
(flake-bytes f)Get the byte array representation of a flake
Get the byte array representation of a flake
(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.
(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.
(flake? x)Checks if the given value is a Flake instance.
Checks if the given value is a Flake instance.
(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.
(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)
(read-method flake-str)Reader method for #flake/flake tagged literals.
Reader method for #flake/flake tagged literals.
(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.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |