Skip to content

Commit a1ec0b8

Browse files
committed
chore: PR feedabck, include index in query cache key
1 parent 386f47f commit a1ec0b8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/ecto/adapter/queryable.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,7 @@ defmodule Ecto.Adapter.Queryable do
105105
%{adapter: adapter, cache: cache} = Ecto.Repo.Registry.lookup(repo_name_or_pid)
106106

107107
counter = Keyword.get(opts, :counter, 0)
108-
109-
query_cache? =
110-
if counter != 0 do
111-
false
112-
else
113-
Keyword.get(opts, :query_cache, true)
114-
end
108+
query_cache? = Keyword.get(opts, :query_cache, true)
115109

116110
{_meta, prepared, _cast_params, dump_params} =
117111
queryable

lib/ecto/query/planner.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ defmodule Ecto.Query.Planner do
136136
def query(query, operation, cache, adapter, counter, query_cache?) do
137137
{query, params, key} = plan(query, operation, adapter)
138138
{cast_params, dump_params} = Enum.unzip(params)
139-
key = if query_cache?, do: key, else: :nocache
139+
140+
key =
141+
cond do
142+
not query_cache? -> :nocache
143+
counter != 0 -> {key, counter}
144+
true -> key
145+
end
146+
140147
query_with_cache(key, query, operation, cache, adapter, counter, cast_params, dump_params)
141148
end
142149

0 commit comments

Comments
 (0)