erlang: uuid generator

2019-03-26 06:46发布

What module/library do you use to generate uuid?

标签: erlang
8条回答
迷人小祖宗
2楼-- · 2019-03-26 07:00

If you don't need follow RFC 4122 you can use now/0 call to generate unique ID without external dependencies, because tuple, generated by now call is absolutely unique inside VM and unique with large probability beetween nodes.

查看更多
姐就是有狂的资本
3楼-- · 2019-03-26 07:03

I recommend using the ossp-uuid nif bindings for Erlang that has rebar support https://github.com/yrashk/erlang-ossp-uuid

ossp_uuid:make(v4, text)
查看更多
可以哭但决不认输i
4楼-- · 2019-03-26 07:04

For future googlers like myself, erlang-uuid from avtobiff works very simply.

查看更多
【Aperson】
5楼-- · 2019-03-26 07:07

Try this one: https://github.com/afiskon/erlang-uuid-v4 The simplest implementation ever.

查看更多
乱世女痞
6楼-- · 2019-03-26 07:12

Why did you use round(math:pow(2, 48))? I think that 1 bsl 48 will work more quickly and code will not lose understanding.

查看更多
劫难
7楼-- · 2019-03-26 07:15

The one I wrote as an example of style and documentation -- based on the zillion recommendations I received from the kind-enough-to-be-mean folks on the Erlang list.

Library: https://gitlab.com/zxq9/zuuid

Docs: http://zxq9.com/projects/zuuid/docs/

PS: Huge thanks to the awesome folks of erlang-questions for taking the time to sharpshoot me on everything. The lib is far better for it.

查看更多
登录 后发表回答