Introduction to {ulid}

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

UUID : Universally Unique Lexicographically Sortable Identifiers

UUID can be suboptimal for many uses-cases because:

Instead, herein is proposed ULID:

ulid() // 01ARZ3NDEKTSV4RRFFQ69G5FAV
 01AN4Z07BY      79KA1307SR9X4MV3

|----------|    |----------------|
 Timestamp          Randomness
   48bits             80bits

Components

Timestamp - 48 bit integer - UNIX-time in milliseconds - Won't run out of space till the year 10889 AD.

Randomness - 80 bits - Cryptographically secure source of randomness, if possible

Sorting

The left-most character must be sorted first, and the right-most character sorted last (lexical order). The default ASCII character set must be used. Within the same millisecond, sort order is not guaranteed.

What's Inside The Tin

The following functions are implemented:

library(ulid)

One

ulid::ULIDgenerate()

Many

(u <- ulid::ULIDgenerate(20))

Unmarshal

unmarshal(u)

Use defined timestamps

(ut <- ts_generate(as.POSIXct("2017-11-01 15:00:00", origin="1970-01-01")))

unmarshal(ut)


Try the ulid package in your browser

Any scripts or data that you put into this service are public.

ulid documentation built on July 9, 2019, 5:03 p.m.