Bunch.ShortRef
(Bunch v1.6.3)
View Source
A wrapper over Erlang/Elixir references that makes them more readable and visually distinguishable.
Erlang references
When printed, Erlang references are quite long: #Reference<0.133031758.722993155.68472>.
Moreover, since they're based on an incremented counter, it's hard to distinguish
between a two created within the same period of time, like #Reference<0.133031758.722993155.68512>
and #Reference<0.133031758.722993155.68519>.
Bunch.ShortRef
Bunch.ShortRef.t/0 stores a usual reference along with first 4 bytes
of its SHA1 hash and when inspected prints only 8 hex digits prepended with #.
Thanks to use of the hash function, similar references have totally different
string representations - the case from the previous example would be #60e0fd2d
and #d4208051.
When to use
Bunch.ShortRef should be used when a reference is to be printed or logged.
It should NOT be used when creating lots of references as it adds a significant
performance overhead.
Summary
Functions
Creates a short reference.