@@ -133,7 +133,7 @@ async Task<bool> CheckCacheAndProcessResultAsync()
133
133
return false ;
134
134
}
135
135
136
- async Task < bool > ProcessKeyAsync ( KeyValuePair < CollectionEntry , IPersistentCollection > me , bool ignoreCache = false )
136
+ Task < bool > ProcessKeyAsync ( KeyValuePair < CollectionEntry , IPersistentCollection > me , bool ignoreCache = false )
137
137
{
138
138
var ce = me . Key ;
139
139
var collection = me . Value ;
@@ -144,18 +144,18 @@ async Task<bool> ProcessKeyAsync(KeyValuePair<CollectionEntry, IPersistentCollec
144
144
// and CollectionEntry.AfterAction())
145
145
// though we clear the queue on flush, it seems like a good idea to guard
146
146
// against potentially null LoadedKey:s
147
- return false ;
147
+ return Task . FromResult < bool > ( false ) ;
148
148
}
149
149
150
150
if ( collection . WasInitialized )
151
151
{
152
152
log . Warn ( "Encountered initialized collection in BatchFetchQueue, this should not happen." ) ;
153
- return false ;
153
+ return Task . FromResult < bool > ( false ) ;
154
154
}
155
155
156
156
if ( checkForEnd && ( index >= keyIndex . Value + batchSize || index == map . Count ) )
157
157
{
158
- return true ;
158
+ return Task . FromResult < bool > ( true ) ;
159
159
}
160
160
if ( collectionPersister . KeyType . IsEqual ( id , ce . LoadedKey , collectionPersister . Factory ) )
161
161
{
@@ -170,17 +170,17 @@ async Task<bool> ProcessKeyAsync(KeyValuePair<CollectionEntry, IPersistentCollec
170
170
if ( ! keyIndex . HasValue || index < keyIndex . Value )
171
171
{
172
172
collectionKeys . Add ( new KeyValuePair < KeyValuePair < CollectionEntry , IPersistentCollection > , int > ( me , index ) ) ;
173
- return false ;
173
+ return Task . FromResult < bool > ( false ) ;
174
174
}
175
175
176
- if ( ! checkCache || ! await ( IsCachedAsync ( ce . LoadedKey , collectionPersister , cancellationToken ) ) . ConfigureAwait ( false ) )
176
+ // No need to check "!checkCache || !IsCached(ce.LoadedKey, collectionPersister)":
177
+ // "batchableCache == null" already means there is no cache, so IsCached can only yield false.
178
+ // (This method is now removed.)
179
+ if ( collectionEntries != null )
177
180
{
178
- if ( collectionEntries != null )
179
- {
180
- collectionEntries [ i ] = ce ;
181
- }
182
- keys [ i ++ ] = ce . LoadedKey ;
181
+ collectionEntries [ i ] = ce ;
183
182
}
183
+ keys [ i ++ ] = ce . LoadedKey ;
184
184
}
185
185
else if ( ignoreCache )
186
186
{
@@ -197,20 +197,20 @@ async Task<bool> ProcessKeyAsync(KeyValuePair<CollectionEntry, IPersistentCollec
197
197
// that are after the demanded key.
198
198
if ( ! keyIndex . HasValue || index < keyIndex . Value + batchSize )
199
199
{
200
- return false ;
200
+ return Task . FromResult < bool > ( false ) ;
201
201
}
202
- return await ( CheckCacheAndProcessResultAsync ( ) ) . ConfigureAwait ( false ) ;
202
+ return CheckCacheAndProcessResultAsync ( ) ;
203
203
}
204
204
if ( i == batchSize )
205
205
{
206
206
i = 1 ; // End of array, start filling again from start
207
207
if ( keyIndex . HasValue )
208
208
{
209
209
checkForEnd = true ;
210
- return index >= keyIndex . Value + batchSize || index == map . Count ;
210
+ return Task . FromResult < bool > ( index >= keyIndex . Value + batchSize || index == map . Count ) ;
211
211
}
212
212
}
213
- return false ;
213
+ return Task . FromResult < bool > ( false ) ;
214
214
}
215
215
}
216
216
@@ -378,17 +378,6 @@ Task<bool> ProcessKeyAsync(EntityKey key, bool ignoreCache = false)
378
378
}
379
379
}
380
380
381
- private async Task < bool > IsCachedAsync ( object collectionKey , ICollectionPersister persister , CancellationToken cancellationToken )
382
- {
383
- cancellationToken . ThrowIfCancellationRequested ( ) ;
384
- if ( persister . HasCache && context . Session . CacheMode . HasFlag ( CacheMode . Get ) )
385
- {
386
- CacheKey cacheKey = context . Session . GenerateCacheKey ( collectionKey , persister . KeyType , persister . Role ) ;
387
- return await ( persister . Cache . Cache . GetAsync ( cacheKey , cancellationToken ) ) . ConfigureAwait ( false ) != null ;
388
- }
389
- return false ;
390
- }
391
-
392
381
/// <summary>
393
382
/// Checks whether the given entity key indexes are cached.
394
383
/// </summary>
0 commit comments