Generate short quasi-unique identifiers (SQUIDs)
squids.Rd
The squids::squids()
function generates a sequence of short quasi-unique
identifiers (see squids-package for more details).
The squids::random_squids()
function is a convenience function that
randomizes the result before returning it.
Arguments
- x
The number of identifiers to generate.
- origin
The origin to use when generating the SQUIDs. This allows you to reproduce the same sequence of SQUIDs. You can easily get an origin with
get_current_origin()
. Theorigin
is a timestamp; an object of classPOSIXct
(see squids-package for more details).- follow
A vector of one or more SQUIDs (or a list; lists are recursively
unlist()
ed); the highest SQUID will be taken, converted to a timestamp, and used asorigin
(well, 0.01 second later), so that the new SQUIDs will follow that sequence.- followBy
When following a vector of SQUIDs, this can be used to specify the distance between the two vectors in centiseconds.
Details
SQUIDs are defined as 8-character strings that express a timestamp (the
number of centiseconds that passed since the UNIX Epoch) in a base 30
decimal system. The lowest possible SQUID is 00000001
(which
corresponds to 1970-01-01 00:00:00 UTC), and the highest possible SQUID is
zzzzzzzz
, which corresponds to 2177-11-28 11:59:59 UTC. More details
are in the squids-package manual page.
Examples
exampleSQUIDs <-
squids::squids(5);
### Show how SQUIDs are the converted date/time
squids::squids_to_datetime(
exampleSQUIDs
);
#> [1] "2025-06-04 20:18:58 UTC" "2025-06-04 20:18:58 UTC"
#> [3] "2025-06-04 20:18:58 UTC" "2025-06-04 20:18:58 UTC"
#> [5] "2025-06-04 20:18:58 UTC"
### These seem the same, but if we take these as
### timestamps (seconds passed since the UNIX Epoch)
### and multiply with 100 to see the centiseconds,
### we see the differences:
as.numeric(
squids::squids_to_datetime(
exampleSQUIDs
)
) * 100;
#> [1] 174906833804 174906833805 174906833806 174906833807 174906833808
### Get a sequence following the first one
squids::squids(5, follow=exampleSQUIDs);
#> 🦑 7zxsbwfm, 7zxsbwfn, 7zxsbwfp, 7zxsbwfq & 7zxsbwfr
### Follow at a distance
squids::squids(
5,
follow=exampleSQUIDs,
followBy = 3
);
#> 🦑 7zxsbwfq, 7zxsbwfr, 7zxsbwfs, 7zxsbwft & 7zxsbwfw