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 | 
|---|---|
| uuid.NULL | A nil UUID object | 
| uuid() uuid.bin() uuid.str() | Get a UUID | 
| uuid.new() | Create a UUID | 
| uuid.fromstr() uuid.frombin() uuid_object:bin() uuid_object:str() | Get a converted UUID | 
| uuid.is_uuid() | Check if the specified value has UUID type | 
| uuid_object:isnil() | Check if a UUID is an all-zero value | 
- 
 uuid.NULL¶
- A nil UUID object. Contains the all-zero UUID value – - 00000000-0000-0000-0000-000000000000.
- 
 uuid.new()¶
- Since version 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] ... - Return: - a UUID - Rtype: - cdata 
- 
 uuid.__call()¶
- Return: - a UUID - Rtype: - cdata 
- 
 uuid.bin([byte-order])¶
- 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
 
 - Return: - a UUID - Rtype: - 16-byte string 
- byte-order (
- 
 uuid.str()¶
- Return: - a UUID - Rtype: - 36-byte binary string 
- 
 uuid.fromstr(uuid-str)¶
- Parameters: - uuid-str (string) – UUID in 36-byte hexadecimal string
 - Return: - converted UUID - Rtype: - cdata 
- uuid-str (
- 
 uuid.frombin(uuid-bin[, byte-order])¶
- Parameters: - Return: - converted UUID - Rtype: - cdata 
- 
 uuid.is_uuid(value)¶
- Since version 2.6.1. - Parameters: - value – a value to check
 - Return: - trueif the specified value is a UUID, and- falseotherwise- Rtype: - bool 
- 
object uuid_object¶
- 
 uuid_object:bin([byte-order])¶
- 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.
 
 - Return: - UUID converted from cdata input value. - Rtype: - 16-byte binary string 
- byte-order (
 - 
 uuid_object:str()¶
- Return: - UUID converted from cdata input value. - Rtype: - 36-byte hexadecimal string 
 
- 
 
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
...