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:

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.