Put the cache with the right key when using a tracking function
This commit is contained in:
parent
769fb778d4
commit
dabc4a00f5
|
@ -58,7 +58,8 @@ def call(%{method: "GET"} = conn, opts) do
|
||||||
cache_resp(conn, opts)
|
cache_resp(conn, opts)
|
||||||
|
|
||||||
{:ok, {content_type, body, tracking_fun_data}} ->
|
{:ok, {content_type, body, tracking_fun_data}} ->
|
||||||
conn = opts.tracking_fun(conn, tracking_fun_data)
|
conn = opts.tracking_fun.(conn, tracking_fun_data)
|
||||||
|
|
||||||
send_cached(conn, {content_type, body})
|
send_cached(conn, {content_type, body})
|
||||||
|
|
||||||
{:ok, record} ->
|
{:ok, record} ->
|
||||||
|
@ -93,7 +94,6 @@ defp cache_resp(conn, opts) do
|
||||||
ttl = Map.get(conn.assigns, :cache_ttl, opts.ttl)
|
ttl = Map.get(conn.assigns, :cache_ttl, opts.ttl)
|
||||||
key = cache_key(conn, opts)
|
key = cache_key(conn, opts)
|
||||||
content_type = content_type(conn)
|
content_type = content_type(conn)
|
||||||
record = {content_type, body}
|
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
unless opts[:tracking_fun] do
|
unless opts[:tracking_fun] do
|
||||||
|
@ -101,7 +101,7 @@ defp cache_resp(conn, opts) do
|
||||||
conn
|
conn
|
||||||
else
|
else
|
||||||
tracking_fun_data = Map.get(conn.assigns, :tracking_fun_data, nil)
|
tracking_fun_data = Map.get(conn.assigns, :tracking_fun_data, nil)
|
||||||
Cachex.put(:web_resp_cache, {content_type, body, tracking_fun_data}, record, ttl: ttl)
|
Cachex.put(:web_resp_cache, key, {content_type, body, tracking_fun_data}, ttl: ttl)
|
||||||
|
|
||||||
opts.tracking_fun.(conn, tracking_fun_data)
|
opts.tracking_fun.(conn, tracking_fun_data)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue