Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Registry

When we started our GenServer-based CacheWorker, you may recall that we used {:global, {:cache, <media_id>}} as the value for the :name option so that we could use the {:cache, <media_id>} tuple as its name. Behind the scenes, our cache processes were being registered using the :global Erlang module, which is started with every running application and serves as a single distributed process register when we have more than one node connected. At this stage, we are still running a single node, thus, as far as we can tell, we could be using Registry, an Elixir process register introduced in version 1.4.

A process register lets us associate a name to a given process. Let's query the :global registry after spawning two cache workers:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content