Skip to content

Commit 38e569c

Browse files
committed
Consolidated adding of queryspaces to be invalidated
1 parent 616a1dd commit 38e569c

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

src/AsyncGenerator.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
- name: GetFieldValue
120120
- name: IsDBNull
121121
- name: WriteLine
122+
- name: AddAction
123+
containingTypeName: ActionQueue
122124
callForwarding: true
123125
cancellationTokens:
124126
guards: true

src/NHibernate/Async/Engine/ActionQueue.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ private async Task AfterExecutionsAsync(CancellationToken cancellationToken)
4646
cancellationToken.ThrowIfCancellationRequested();
4747
if (session.Factory.Settings.IsQueryCacheEnabled)
4848
{
49-
await (session.Factory.UpdateTimestampsCache.PreInvalidateAsync(executedSpaces.ToArray(), cancellationToken)).ConfigureAwait(false);
49+
var spaces = executedSpaces.ToArray();
50+
afterTransactionProcesses.AddSpacesToInvalidate(spaces);
51+
await (session.Factory.UpdateTimestampsCache.PreInvalidateAsync(spaces, cancellationToken)).ConfigureAwait(false);
5052
}
5153
executedSpaces.Clear();
5254
}
@@ -90,11 +92,11 @@ public async Task ExecuteInsertsAsync(CancellationToken cancellationToken)
9092
cancellationToken.ThrowIfCancellationRequested();
9193
try
9294
{
93-
await ExecuteActionsAsync(insertions, cancellationToken);
95+
await (ExecuteActionsAsync(insertions, cancellationToken)).ConfigureAwait(false);
9496
}
9597
finally
9698
{
97-
await AfterExecutionsAsync(cancellationToken);
99+
await (AfterExecutionsAsync(cancellationToken)).ConfigureAwait(false);
98100
}
99101
}
100102

src/NHibernate/Async/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected virtual async Task CoordinateSharedCacheCleanupAsync(ISessionImplement
4343

4444
if (session.IsEventSource)
4545
{
46-
((IEventSource) session).ActionQueue.AddAction(action);
46+
((IEventSource)session).ActionQueue.AddAction(action);
4747
}
4848
}
4949

@@ -207,4 +207,4 @@ public async Task DoWorkAsync(DbConnection connection, DbTransaction transaction
207207
}
208208
}
209209
}
210-
}
210+
}

src/NHibernate/Engine/ActionQueue.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ private void AfterExecutions()
150150
{
151151
if (session.Factory.Settings.IsQueryCacheEnabled)
152152
{
153-
session.Factory.UpdateTimestampsCache.PreInvalidate(executedSpaces.ToArray());
153+
var spaces = executedSpaces.ToArray();
154+
afterTransactionProcesses.AddSpacesToInvalidate(spaces);
155+
session.Factory.UpdateTimestampsCache.PreInvalidate(spaces);
154156
}
155157
executedSpaces.Clear();
156158
}
@@ -169,28 +171,23 @@ public void Execute(IExecutable executable)
169171

170172
private void InnerExecute(IExecutable executable)
171173
{
172-
if (executable.PropertySpaces != null)
173-
{
174-
executedSpaces.UnionWith(executable.PropertySpaces);
175-
}
176174
try
177175
{
178176
executable.Execute();
179177
}
180178
finally
181179
{
180+
if (executable.PropertySpaces != null)
181+
{
182+
executedSpaces.UnionWith(executable.PropertySpaces);
183+
}
182184
RegisterCleanupActions(executable);
183185
}
184186
}
185187

186188
private void RegisterCleanupActions(IExecutable executable)
187189
{
188190
beforeTransactionProcesses.Register(executable.BeforeTransactionCompletionProcess);
189-
if (session.Factory.Settings.IsQueryCacheEnabled)
190-
{
191-
string[] spaces = executable.PropertySpaces;
192-
afterTransactionProcesses.AddSpacesToInvalidate(spaces);
193-
}
194191
afterTransactionProcesses.Register(executable.AfterTransactionCompletionProcess);
195192
}
196193

0 commit comments

Comments
 (0)