Issue #19735 has been updated by nevans (Nicholas Evans).
Description updated
I hadn't realized that `"random/formatter"` belonged to `securerandom`. I
closed the `ruby` PR and created a new PR here:
https://github.com/ruby/securerandom/pull/19. There was also another earlier PR which
looks almost identical to my original PR:
https://github.com/ruby/securerandom/pull/15. I
updated my PR to provide an alternative tradeoff: allow up to 12 bits of extra timestamp
precision, at the cost of code complexity and a small performance penalty. I personally
would be satisfied with either PR.
----------------------------------------
Feature #19735: Add support for UUID version 7
https://bugs.ruby-lang.org/issues/19735#change-103739
* Author: nevans (Nicholas Evans)
* Status: Open
* Priority: Normal
----------------------------------------
Although the specification for UUIDv7 is still in draft, the UUIDv7 algorithm has been
stable as the RFC progresses to completion.
Version 7 UUIDs can be very useful, because they are lexographically sortable, which can
improve e.g: database index locality. See section 6.10 of the draft specification for
further explanation:
https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/
```ruby
require 'random/formatter'
Random.uuid_v7 # => "0188ca50-fcc0-7881-b5c5-6d55cd8fc373"
Random.uuid_v7 # => "0188ca51-0069-7304-be2e-0c3cd908789b"
Random.uuid_v7 # => "0188ca51-04aa-7b57-a6ec-c49573412a9d"
Random.uuid_v7 # => "0188ca51-0853-7979-ae37-485460e9f4f1"
# or
prng = Random.new
prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98"
```
PR here:
https://github.com/ruby/securerandom/pull/19
--
https://bugs.ruby-lang.org/