@@ -6,25 +6,21 @@ Ordered-time Codec
66
77.. attention ::
88
9- :ref: `Version 6, reordered time UUIDs <rfc4122.version6 >` are a new version
10- of UUID that eliminate the need for the ordered-time codec. If you aren't
11- currently using the ordered-time codec, and you need time-based, sortable
12- UUIDs, consider using version 6 UUIDs.
13-
14- UUIDs arrange their bytes according to the standard recommended by `RFC 4122 `_.
15- Unfortunately, this means the bytes aren't in an arrangement that supports
16- sorting by creation time or an otherwise incrementing value. The Percona
17- article, "`Storing UUID Values in MySQL `_," explains at length the problems this
18- can cause. It also recommends a solution: the *ordered-time UUID *.
19-
20- RFC 4122 version 1, Gregorian time UUIDs rearrange the bytes of the time fields
21- so that the lowest bytes appear first, the middle bytes are next, and the
22- highest bytes come last. Logical sorting is not possible with this arrangement.
23-
24- An ordered-time UUID is a version 1 UUID with the time fields arranged in
25- logical order so that the UUIDs can be sorted by creation time. These UUIDs are
26- *monotonically increasing *, each one coming after the previously-created one, in
27- a proper sort order.
9+ The :php:class: `Ramsey\\ Uuid\\ Codec\\ OrderedTimeCodec ` class is deprecated. Please migrate to
10+ :ref: `version 6, reordered Gregorian time UUIDs <rfc4122.version6 >`.
11+
12+ UUIDs arrange their bytes according to the standard recommended by `RFC 9562 `_ (formerly `RFC 4122 `_). Unfortunately,
13+ this means the bytes aren't in an arrangement that supports sorting by creation time or an otherwise incrementing value.
14+ The Percona article, "`Storing UUID Values in MySQL `_," explains at length the problems this can cause. It also
15+ recommends a solution: the *ordered-time UUID *.
16+
17+ `RFC 9562 version 1, Gregorian time UUIDs <https://www.rfc-editor.org/rfc/rfc9562#section-5.1 >`_ rearrange the bytes of
18+ the time fields so that the lowest bytes appear first, the middle bytes are next, and the highest bytes come last.
19+ Logical sorting is not possible with this arrangement.
20+
21+ An ordered-time UUID is a version 1 UUID with the time fields arranged in logical order so that the UUIDs can be sorted
22+ by creation time. These UUIDs are *monotonically increasing *, each one coming after the previously-created one, in a
23+ proper sort order.
2824
2925.. code-block :: php
3026 :caption: Use the ordered-time codec to generate a version 1 UUID
@@ -49,8 +45,7 @@ a proper sort order.
4945 bin2hex($orderedTimeUuid->getBytes())
5046 );
5147
52- This will use the ordered-time codec to generate a version 1 UUID and will print
53- out details about the UUID similar to these:
48+ This will use the ordered-time codec to generate a version 1 UUID and will print out details about the UUID similar to these:
5449
5550.. code-block :: text
5651
@@ -62,25 +57,22 @@ out details about the UUID similar to these:
6257
6358 .. attention ::
6459
65- Only the byte representation is rearranged. The string representation
66- follows the format of a standard version 1 UUID. This means only the byte
67- representation of an ordered-time codec encoded UUID may be used for
68- sorting, such as with database results.
60+ Only the byte representation is rearranged. The string representation follows the format of a standard version 1
61+ UUID. This means only the byte representation of an ordered-time codec encoded UUID may be used for sorting, such as
62+ with database results.
6963
70- To store the byte representation to a database field, see
71- :ref: `database.bytes `.
64+ To store the byte representation to a database field, see :ref: `database.bytes `.
7265
7366.. hint ::
7467
75- If you use this codec and store the bytes of the UUID to the database, as
76- recommended above, you will need to use this codec to decode the bytes, as
77- well. Otherwise, the UUID string value will be incorrect.
68+ If you use this codec and store the bytes of the UUID to the database, as recommended above, you will need to use
69+ this codec to decode the bytes, as well. Otherwise, the UUID string value will be incorrect.
7870
7971 .. code-block :: php
8072
8173 // Using a factory configured with the OrderedTimeCodec, as shown above.
8274 $orderedTimeUuid = $factory->fromBytes($bytes);
8375
84-
85- .. _RFC 4122 : https://tools.ietf .org/html/rfc4122
86- .. _Storing UUID Values in MySQL : https://www.percona.com/blog/2014/12/19/ store-uuid-optimized-way/
76+ .. _ RFC 4122 : https://www.rfc-editor.org/rfc/rfc4122
77+ .. _RFC 9562 : https://www.rfc-editor .org/rfc/rfc9562
78+ .. _Storing UUID Values in MySQL : https://www.percona.com/blog/store-uuid-optimized-way/
0 commit comments