Function: uuid-v7
uuid-v7 is a byte-compiled function defined in uuid.el.gz.
Signature
(uuid-v7 &key RNG)
Documentation
Return a new UUIDv7 ID.
The UUIDv7 uses a timestamp instead of being purely random, which makes it more suitable for use cases such as database keys.
RNG is an alternate random number function which should take a single
argument, the limit (exclusive) for the random number, and return an
integer between 0 and that number. See uuid-v4 for more details on
the expected behavior of this function.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/uuid.el.gz
(cl-defun uuid-v7 (&key rng)
"Return a new UUIDv7 ID.
The UUIDv7 uses a timestamp instead of being purely random, which makes
it more suitable for use cases such as database keys.
RNG is an alternate random number function which should take a single
argument, the limit (exclusive) for the random number, and return an
integer between 0 and that number. See `uuid-v4' for more details on
the expected behavior of this function."
(uuid--from-parts (floor (* (float-time) 1000))
(uuid--random-bits 12 rng)
(uuid--random-bits 62 rng)
7 2))