Documentation

OrderedTimeCodec extends StringCodec
in package

OrderedTimeCodec encodes and decodes a UUID, optimizing the byte order for more efficient storage

For binary representations of version 1 UUID, this codec may be used to reorganize the time fields, making the UUID closer to sequential when storing the bytes. According to Percona, this optimization can improve database INSERTs and SELECTs using the UUID column as a key.

The string representation of the UUID will remain unchanged. Only the binary representation is reordered.

PLEASE NOTE: Binary representations of UUIDs encoded with this codec must be decoded with this codec. Decoding using another codec can result in malformed UUIDs.

Tags
link

Storing UUID Values in MySQL

psalm-immutable

Table of Contents

$builder  : UuidBuilderInterface
__construct()  : mixed
Constructs a StringCodec
decode()  : UuidInterface
Returns a UuidInterface derived from a hexadecimal string representation
decodeBytes()  : UuidInterface
Returns a UuidInterface derived from an ordered-time binary string representation
encode()  : string
Returns a hexadecimal string representation of a UuidInterface
encodeBinary()  : string
Returns a binary string representation of a UUID, with the timestamp fields rearranged for optimized storage
getBuilder()  : UuidBuilderInterface
Returns the UUID builder
getBytes()  : string
Returns a byte string of the UUID

Properties

Methods

decode()

Returns a UuidInterface derived from a hexadecimal string representation

public decode(string $encodedUuid) : UuidInterface
Parameters
$encodedUuid : string

The hexadecimal string representation to convert into a UuidInterface instance

Tags
throws
InvalidUuidStringException
inheritDoc
Return values
UuidInterface

An instance of a UUID decoded from a hexadecimal string representation

decodeBytes()

Returns a UuidInterface derived from an ordered-time binary string representation

public decodeBytes(string $bytes) : UuidInterface
Parameters
$bytes : string

The binary string representation to convert into a UuidInterface instance

Tags
throws
InvalidArgumentException

if $bytes is an invalid length

inheritDoc
Return values
UuidInterface

An instance of a UUID decoded from a binary string representation

encode()

Returns a hexadecimal string representation of a UuidInterface

public encode(UuidInterface $uuid) : string
Parameters
$uuid : UuidInterface

The UUID for which to create a hexadecimal string representation

Return values
string

Hexadecimal string representation of a UUID

encodeBinary()

Returns a binary string representation of a UUID, with the timestamp fields rearranged for optimized storage

public encodeBinary(UuidInterface $uuid) : string
Parameters
$uuid : UuidInterface

The UUID for which to create a binary string representation

Tags
inheritDoc
psalm-return

non-empty-string

psalm-suppress

MoreSpecificReturnType we know that the retrieved string is never empty

psalm-suppress

LessSpecificReturnStatement we know that the retrieved string is never empty

Return values
string

Binary string representation of a UUID

getBytes()

Returns a byte string of the UUID

protected getBytes(string $encodedUuid) : string
Parameters
$encodedUuid : string
Return values
string

Search results