title: How do you communicate with an Elixir Agent from within a Phoenix Controller?
body: <p>It's great to be learning a language early enough in its life when the language's creator answers your questions! Well, my question is - how do you communicate with an Agent from within a Phoenix controller method? I've got this in hello_blockchain/monitor.ex:</p>
  
  <pre><code>defmodule HelloBlockchain.Monitor do
    def start_link do
      Agent.start_link(fn -&gt; %{} end)
    end
  
    def put(pid, key, value) do
      Agent.update(pid, &amp;Map.put(&amp;1, key, value))
    end
  
    def get(pid, key) do
      Agent.get(pid, &amp;Map.get(&amp;1, key))
    end
  end
  </code></pre>
  
  <p>and in my hello_blockchain_web/controllers/block_controller.ex, I want to save a value in a controller action (list), and retrieve it in the same action next time it's called. But I need the Agent's pid to do this. It seems I need to save it too. Or I could use a named Agent. But I'd need a way to save this name. It seems like a Catch-22. What am I missing? </p>