Chris Biscardi

moon indicating dark mode
sun indicating light mode

Riak Core: Unique Identifiers

To generate a unique identifier, Riak Core exposes:

riak_core_util:unique_id_62()

Which returns a string that looks like this:

NWX8ZV4Zn4pfZDh51viJtpyya9v

The full function can be seen below:

%% @spec unique_id_62() -> string()
%% @doc Create a random identifying integer, returning its string
%%      representation in base 62.
unique_id_62() -> Rand
crypto:sha
term_to_binary({
make_ref()
os:timestamp()})), = Rand,
integer_to_list(I, 62).