Skip to content

Commit

Permalink
write_results_to_cache p.275 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 11, 2019
1 parent cf06b62 commit ca3ffe5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apps/info_sys/lib/info_sys.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ defmodule InfoSys do
|> Enum.take(opts[:limit])
end

defp async_query(backend, query, opts) do
Task.Supervisor.async_nolink(InfoSys.TaskSupervisor,
backend, :compute, [query, opts], shutdown: :brutal_kill
)
end

defp fetch_cached_results(backends, query, opts) do
{uncached_backends, results} =
Enum.reduce(
Expand All @@ -44,9 +50,9 @@ defmodule InfoSys do
{uncached_backends, List.flatten(results)}
end

defp async_query(backend, query, opts) do
Task.Supervisor.async_nolink(InfoSys.TaskSupervisor,
backend, :compute, [query, opts], shutdown: :brutal_kill
)
defp write_results_to_cache(results, query, opts) do
Enum.map(results, fn %Result{backend: backend} = result ->
:ok = Cache.put({backend.name(), query, opts[:limit]}, result)
end)
end
end

0 comments on commit ca3ffe5

Please sign in to comment.