Skip to content

Commit d476086

Browse files
fixup! Implement multiple get and put for query cache and query batch
Fix some more troubles, see review on #1718
1 parent 49d3ba7 commit d476086

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/NHibernate/Async/Multi/QueryBatch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ private async Task ExecuteBatchedAsync(CancellationToken cancellationToken)
143143
}
144144
}
145145

146+
await (PutCacheableResultsAsync(cancellationToken)).ConfigureAwait(false);
147+
146148
foreach (var multiSource in _queries)
147149
{
148150
multiSource.ProcessResults();
@@ -159,8 +161,6 @@ private async Task ExecuteBatchedAsync(CancellationToken cancellationToken)
159161
resultSetsCommand.Sql);
160162
}
161163

162-
await (PutCacheableResultsAsync(cancellationToken)).ConfigureAwait(false);
163-
164164
if (statsEnabled)
165165
{
166166
stopWatch.Stop();

src/NHibernate/Multi/QueryBatch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ private void ExecuteBatched()
169169
}
170170
}
171171

172+
PutCacheableResults();
173+
172174
foreach (var multiSource in _queries)
173175
{
174176
multiSource.ProcessResults();
@@ -184,8 +186,6 @@ private void ExecuteBatched()
184186
resultSetsCommand.Sql);
185187
}
186188

187-
PutCacheableResults();
188-
189189
if (statsEnabled)
190190
{
191191
stopWatch.Stop();

src/NHibernate/Multi/QueryBatchItemBase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public IEnumerable<Func<DbDataReader, int>> GetResultSetHandler()
147147
//Skip processing for items already loaded from cache
148148
if (queryInfo.IsResultFromCache)
149149
{
150-
queryInfo.Result = loader.TransformCacheableResults(queryParameters, queryInfo.CacheKey.ResultTransformer, queryInfo.Result);
151150
continue;
152151
}
153152

@@ -217,11 +216,16 @@ public void ProcessResults()
217216

218217
for (var i = 0; i < _queryInfos.Count; i++)
219218
{
219+
var queryInfo = _queryInfos[i];
220220
if (_subselectResultKeys[i] != null)
221221
{
222-
var queryInfo = _queryInfos[i];
223222
queryInfo.Loader.CreateSubselects(_subselectResultKeys[i], queryInfo.Parameters, Session);
224223
}
224+
225+
if (queryInfo.IsCacheable)
226+
queryInfo.Result =
227+
queryInfo.Loader.TransformCacheableResults(
228+
queryInfo.Parameters, queryInfo.CacheKey.ResultTransformer, queryInfo.Result);
225229
}
226230
AfterLoadCallback?.Invoke(GetResults());
227231
}

0 commit comments

Comments
 (0)