Module uuid
A "UUID" is a Universally unique identifier. If an application requires that a value be unique only within a single computer or on a single database, then a simple counter is better than a UUID, because getting a UUID is time-consuming (it requires a syscall). For clusters of computers, or widely distributed applications, UUIDs are better. Tarantool generates UUIDs following the rules for RFC 4122 version 4 variant 1.
Below is list of all uuid functions and members.
Name | Use |
|---|---|
A nil UUID object | |
Get a UUID | |
Create a UUID | |
uuid.fromstr() | Get a converted UUID |
Check if the specified value has UUID type | |
Check if a UUID is an all-zero value |
A nil UUID object. Contains the all-zero UUID value –
00000000-0000-0000-0000-000000000000.
Since: 2.4.1
Create a UUID sequence. You can use it in an index over a
UUID field. For example, to create such
index for a space named test, say:
tarantool> box.space.test:create_index("pk", {parts={{field = 1, type = 'uuid'}}})---...
Now you can insert UUIDs into the space:
tarantool> box.space.test:insert{uuid.new()}---- [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]...tarantool> box.space.test:insert{uuid.fromstr('64d22e4d-ac92-4a23-899a-e59f34af5479')}---- [64d22e4d-ac92-4a23-899a-e59f34af5479]...tarantool> box.space.test:select{}---- - [64d22e4d-ac92-4a23-899a-e59f34af5479]- [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]...
Returns
UUID
Return type
cdata
Returns
a UUID
Return type
cdata
Parameters:
-
byte-order(string) — Byte order of the resulting UUID:'l'– little-endian'b'– big-endian'h','host'– endianness depends on host (default)'n','network'– endianness depends on network
Returns
a UUID
Return type
16-byte string
Returns
a UUID
Return type
36-byte binary string
Parameters:
uuid-str(string) — UUID in 36-byte hexadecimal string
Returns
converted UUID
Return type
cdata
Parameters:
-
uuid-bin(string) — UUID in 16-byte binary string -
byte-order(string) — Byte order of the given string:'l'– little-endian,'b'– big-endian,'h','host'– endianness depends on host (default),'n','network'– endianness depends on network.
Returns
converted UUID
Return type
cdata
Since: 2.6.1
Parameters:
value— a value to check
Returns
true if the specified value is a UUID, and false otherwise
Return type
bool
The uuid_object is a UUID object returned by
uuid.new(), uuid(),
uuid.fromstr(), and uuid.frombin().
Parameters:
-
byte-order(string) — Byte order of the resulting UUID:'l'– little-endian,'b'– big-endian,'h','host'– endianness depends on host (default),'n','network'– endianness depends on network.
Returns
UUID converted from cdata input value.
Return type
16-byte binary string
Returns
UUID converted from cdata input value.
Return type
36-byte hexadecimal string
The all-zero UUID value can be expressed as uuid.NULL, or
as uuid.fromstr('00000000-0000-0000-0000-000000000000'). The
comparison with an all-zero value can also be expressed as
uuid_with_type_cdata == uuid.NULL.
Returns
true if the value is all zero, otherwise
false.
Return type
bool
tarantool> uuid = require('uuid')---...tarantool> uuid(), uuid.bin(), uuid.str()---- 16ffedc8-cbae-4f93-a05e-349f3ab70baa- !!binary FvG+Vy1MfUC6kIyeM81DYw==- 67c999d2-5dce-4e58-be16-ac1bcb93160f...tarantool> uu = uuid()---...tarantool> #uu:bin(), #uu:str(), type(uu), uu:isnil()---- 16- 36- cdata- false...