(generate-squuid)
Return a new v8 sequential UUID, or SQUUID. The most significant 48 bits are created from a timestamp representing the current time, which always increments in value. The least significant 80 bits are derived from a base v4 UUID; since 6 bits are reserved (4 for the version and 2 for the variant), this leaves 74 random bits, allowing for about 18.9 sextillion random segments.
The timestamp is coerced to millisecond resolution. Due to the 48 bit maximum on the timestamp, the latest time supported is August 2, 10889.
In case that this function (or generate-squuid*
) is called multiple times
in the same millisecond, subsequent SQUUIDs are created by incrementing the
base UUID and thus the random segment of the SQUUID. An exception is thrown
in the unlikely case where all 74 random bits are 1s and incrementing can no
longer occur.
Return a new v8 sequential UUID, or SQUUID. The most significant 48 bits are created from a timestamp representing the current time, which always increments in value. The least significant 80 bits are derived from a base v4 UUID; since 6 bits are reserved (4 for the version and 2 for the variant), this leaves 74 random bits, allowing for about 18.9 sextillion random segments. The timestamp is coerced to millisecond resolution. Due to the 48 bit maximum on the timestamp, the latest time supported is August 2, 10889. In case that this function (or `generate-squuid*`) is called multiple times in the same millisecond, subsequent SQUUIDs are created by incrementing the base UUID and thus the random segment of the SQUUID. An exception is thrown in the unlikely case where all 74 random bits are 1s and incrementing can no longer occur.
(generate-squuid*)
Return a map containing the following: :squuid The v8 sequential UUID made up of a base UUID and timestamp. :base-uuid The base v4 UUID that provides the lower 80 bits. :timestamp The timestamp that provides the higher 48 bits.
See generate-squuid
for more details.
Return a map containing the following: :squuid The v8 sequential UUID made up of a base UUID and timestamp. :base-uuid The base v4 UUID that provides the lower 80 bits. :timestamp The timestamp that provides the higher 48 bits. See `generate-squuid` for more details.
(reset-all!)
Reset such that the starting timestamp and UUIDs are zeroed out. This function is intended for use in development/testing.
Reset such that the starting timestamp and UUIDs are zeroed out. This function is intended for use in development/testing.
(time->uuid ts)
Convert a timestamp to a UUID. The upper 48 bits represent
the timestamp, while the lower 80 bits are fixed at
8FFF-8FFF-FFFFFFFFFFFF
.
Convert a timestamp to a UUID. The upper 48 bits represent the timestamp, while the lower 80 bits are fixed at `8FFF-8FFF-FFFFFFFFFFFF`.
(uuid->time uuid)
Convert a previously generated uuid
to its corresponding timestamp.
Returns a java.time.Instant object in Clojure, #inst in ClojureScript.
Convert a previously generated `uuid` to its corresponding timestamp. Returns a java.time.Instant object in Clojure, #inst in ClojureScript.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close