So I installed cachex in my phoenix app by adding it to my deps and performing a mix deps.get.
Now in the docs it says to " 2. Ensure cachex is started before your application:"
I’m not sure how to make sure it starts before my application, I have this so far and it is after my app starts:
def application do
[
mod: {Realtime.Application, []},
extra_applications: [:cachex, :logger, :runtime_tools, :extwitter]
]
end
The 2nd part of the install is:
The typical use of Cachex is to set up using a Supervisor, so that it can be handled automatically:
Supervisor.start_link(
[ worker(Cachex, [:my_cache, ]) ]
)
So this would be the application.ex file. Do I add to the children array?
def start(_type, _args) do
# List all child processes to be supervised
children = [
# Start the Ecto repository
Realtime.Repo,
# Start the endpoint when the application starts
RealtimeWeb.Endpoint,
# Starts a worker by calling: Realtime.Worker.start_link(arg)
# {Realtime.Worker, arg},
RealtimeWeb.Presence
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Realtime.Supervisor]
Supervisor.start_link(children, opts)
end
Thanks!