What module/library do you use to generate uuid?
相关问题
- Is “new” in Erlang part of the official standard a
- how to create a keep-alive process in Erlang
- ejabberd and Erlang installation with lager_transf
- Encrypt (cryptojs) - Decrypt (erlang)
- How to use erlang-examples
相关文章
- How do I modify a record in erlang?
- Check active timers in Erlang
- undefined function maps:to_json/1
- How to convert datetime() to timestamp() in Erlang
- what good orm api will work well with scala or erl
- GC performance in Erlang
- When to “let it crash” and when to defend the code
- Intercept login/logout ejabberd
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.I recommend using the ossp-uuid nif bindings for Erlang that has rebar support https://github.com/yrashk/erlang-ossp-uuid
For future googlers like myself, erlang-uuid from avtobiff works very simply.
Try this one: https://github.com/afiskon/erlang-uuid-v4 The simplest implementation ever.
Why did you use
round(math:pow(2, 48))
? I think that1 bsl 48
will work more quickly and code will not lose understanding.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.