[erlang-questions] Generating readable unique IDs for use outside erlang

Max E. Kuznecov mek@REDACTED
Thu Feb 10 15:40:51 CET 2011


Looks like erlang:phash2/1 may help:

> erlang:phash2({node(), now()}).
59735927

2011/2/10 Dave Challis <dsc@REDACTED>:
> Is there a good (and fast) way of generating a unique id for use outside
> Erlang?
>
> The best method I can find for generating a unique id is to use:
> {node(), now()}
>
> Which generates something like:
> {foo@REDACTED,{1297,347375,276224}}
>
> This works great, and is what I use within erlang.
>
> However, it looks a bit meaningless is likely to confuse users of the
> non-erlang application that uses it - is there a nice way to turn that into
> an integer, or series of integers instead?
>
> E.g. turning the above into:
> 3473290872_1297_347375_276224
> (or ideally a single integer)
>
> would be fine, but I'm not sure how to get an integer from a term.
>
> Chances are I'll be generating hundreds of thousands to several million of
> these, so I'm also a bit concerned about efficiency - turning the {node(),
> now()} tuple into a string would no doubt take up more memory (and some
> processing time).
>
> Any suggestions on this?
>
> --
> Dave Challis
> dsc@REDACTED
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>



-- 
~syhpoon


More information about the erlang-questions mailing list