70 %
Chris Biscardi

Riak Core: Unique Identifiers

To generate a unique identifier, Riak Core exposes:

erlang
riak_core_util:unique_id_62()

Which returns a string that looks like this:

erlang
NWX8ZV4Zn4pfZDh51viJtpyya9v

The full function can be seen below:

erlang
%% @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).