@@ -106,10 +106,10 @@ public async ValueTask FlushAsync()
106106 for ( int i = 0 , l = CacheLayers . Length ; i < l ; i ++ )
107107 {
108108 var layer = CacheLayers [ i ] ;
109- await layer . FlushAsync ( ) ;
109+ await layer . FlushAsync ( ) . ConfigureAwait ( false ) ;
110110 }
111111
112- await Extensions . OnCacheFlushAsync ( ) ;
112+ await Extensions . OnCacheFlushAsync ( ) . ConfigureAwait ( false ) ;
113113 }
114114
115115 /// <inheritdoc/>
@@ -120,7 +120,7 @@ public async ValueTask CleanupAsync()
120120 for ( int i = 0 , l = CacheLayers . Length ; i < l ; i ++ )
121121 {
122122 var layer = CacheLayers [ i ] ;
123- await layer . CleanupAsync ( ) ;
123+ await layer . CleanupAsync ( ) . ConfigureAwait ( false ) ;
124124 }
125125 }
126126
@@ -137,10 +137,10 @@ public async ValueTask EvictAsync(string cacheKey)
137137 for ( int i = 0 , l = CacheLayers . Length ; i < l ; i ++ )
138138 {
139139 var layer = CacheLayers [ i ] ;
140- await layer . EvictAsync ( cacheKey ) ;
140+ await layer . EvictAsync ( cacheKey ) . ConfigureAwait ( false ) ;
141141 }
142142
143- await Extensions . OnCacheEvictionAsync ( cacheKey ) ;
143+ await Extensions . OnCacheEvictionAsync ( cacheKey ) . ConfigureAwait ( false ) ;
144144 }
145145
146146 /// <inheritdoc/>
@@ -154,7 +154,7 @@ public async ValueTask<CacheEntry<T>> SetAsync<T>(string cacheKey, T value, Time
154154 }
155155
156156 var cacheEntry = new CacheEntry < T > ( value , timeToLive ) ;
157- await InternalSetAsync ( cacheKey , cacheEntry , CacheUpdateType . AddOrUpdateEntry ) ;
157+ await InternalSetAsync ( cacheKey , cacheEntry , CacheUpdateType . AddOrUpdateEntry ) . ConfigureAwait ( false ) ;
158158 return cacheEntry ;
159159 }
160160
@@ -173,7 +173,7 @@ public async ValueTask SetAsync<T>(string cacheKey, CacheEntry<T> cacheEntry)
173173 throw new ArgumentNullException ( nameof ( cacheEntry ) ) ;
174174 }
175175
176- await InternalSetAsync ( cacheKey , cacheEntry , CacheUpdateType . AddOrUpdateEntry ) ;
176+ await InternalSetAsync ( cacheKey , cacheEntry , CacheUpdateType . AddOrUpdateEntry ) . ConfigureAwait ( false ) ;
177177 }
178178
179179 private async ValueTask InternalSetAsync < T > ( string cacheKey , CacheEntry < T > cacheEntry , CacheUpdateType cacheUpdateType )
@@ -184,15 +184,15 @@ private async ValueTask InternalSetAsync<T>(string cacheKey, CacheEntry<T> cache
184184
185185 try
186186 {
187- await layer . SetAsync ( cacheKey , cacheEntry ) ;
187+ await layer . SetAsync ( cacheKey , cacheEntry ) . ConfigureAwait ( false ) ;
188188 }
189189 catch ( CacheSerializationException ex )
190190 {
191191 Logger . LogWarning ( ex , "Unable to set CacheKey={CacheKey} on CacheLayer={CacheLayer} due to an exception. This will result in cache misses on this layer." , cacheKey , layer . GetType ( ) ) ;
192192 }
193193 }
194194
195- await Extensions . OnCacheUpdateAsync ( cacheKey , cacheEntry . Expiry , cacheUpdateType ) ;
195+ await Extensions . OnCacheUpdateAsync ( cacheKey , cacheEntry . Expiry , cacheUpdateType ) . ConfigureAwait ( false ) ;
196196 }
197197
198198 /// <inheritdoc/>
@@ -208,11 +208,11 @@ private async ValueTask InternalSetAsync<T>(string cacheKey, CacheEntry<T> cache
208208 for ( var layerIndex = 0 ; layerIndex < CacheLayers . Length ; layerIndex ++ )
209209 {
210210 var layer = CacheLayers [ layerIndex ] ;
211- if ( await layer . IsAvailableAsync ( cacheKey ) )
211+ if ( await layer . IsAvailableAsync ( cacheKey ) . ConfigureAwait ( false ) )
212212 {
213213 try
214214 {
215- var cacheEntry = await layer . GetAsync < T > ( cacheKey ) ;
215+ var cacheEntry = await layer . GetAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
216216 if ( cacheEntry != default )
217217 {
218218 return cacheEntry ;
@@ -234,11 +234,11 @@ private async ValueTask InternalSetAsync<T>(string cacheKey, CacheEntry<T> cache
234234 for ( var layerIndex = 0 ; layerIndex < CacheLayers . Length ; layerIndex ++ )
235235 {
236236 var layer = CacheLayers [ layerIndex ] ;
237- if ( await layer . IsAvailableAsync ( cacheKey ) )
237+ if ( await layer . IsAvailableAsync ( cacheKey ) . ConfigureAwait ( false ) )
238238 {
239239 try
240240 {
241- var cacheEntry = await layer . GetAsync < T > ( cacheKey ) ;
241+ var cacheEntry = await layer . GetAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
242242 if ( cacheEntry != default )
243243 {
244244 return ( layerIndex , cacheEntry ) ;
@@ -270,7 +270,7 @@ public async ValueTask<T> GetOrSetAsync<T>(string cacheKey, Func<T, Task<T>> val
270270 }
271271
272272 var currentTime = DateTimeProvider . Now ;
273- var cacheEntryPoint = await GetWithLayerIndexAsync < T > ( cacheKey ) ;
273+ var cacheEntryPoint = await GetWithLayerIndexAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
274274 var cacheEntryStatus = CacheEntryStatus . Stale ;
275275 if ( cacheEntryPoint != default )
276276 {
@@ -302,7 +302,7 @@ public async ValueTask<T> GetOrSetAsync<T>(string cacheKey, Func<T, Task<T>> val
302302 cacheEntryStatus = CacheEntryStatus . Miss ;
303303 }
304304
305- return ( await RefreshValueAsync ( cacheKey , valueFactory , settings , cacheEntryStatus ) ) ! . Value ! ;
305+ return ( await RefreshValueAsync ( cacheKey , valueFactory , settings , cacheEntryStatus ) . ConfigureAwait ( false ) ) ! . Value ! ;
306306 }
307307
308308 private async ValueTask BackPopulateCacheAsync < T > ( int fromIndexExclusive , string cacheKey , CacheEntry < T > cacheEntry )
@@ -314,9 +314,9 @@ private async ValueTask BackPopulateCacheAsync<T>(int fromIndexExclusive, string
314314 for ( ; -- fromIndexExclusive >= 0 ; )
315315 {
316316 var previousLayer = CacheLayers [ fromIndexExclusive ] ;
317- if ( await previousLayer . IsAvailableAsync ( cacheKey ) )
317+ if ( await previousLayer . IsAvailableAsync ( cacheKey ) . ConfigureAwait ( false ) )
318318 {
319- await previousLayer . SetAsync ( cacheKey , cacheEntry ) ;
319+ await previousLayer . SetAsync ( cacheKey , cacheEntry ) . ConfigureAwait ( false ) ;
320320 }
321321 }
322322 }
@@ -333,7 +333,7 @@ private async ValueTask BackPopulateCacheAsync<T>(int fromIndexExclusive, string
333333 {
334334 try
335335 {
336- var previousEntry = await GetAsync < T > ( cacheKey ) ;
336+ var previousEntry = await GetAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
337337 if ( previousEntry != default && entryStatus == CacheEntryStatus . Miss && previousEntry . Expiry >= DateTimeProvider . Now )
338338 {
339339 //The Cache Stack will always return an unexpired value if one exists.
@@ -344,26 +344,26 @@ private async ValueTask BackPopulateCacheAsync<T>(int fromIndexExclusive, string
344344 return previousEntry ;
345345 }
346346
347- await using var distributedLock = await Extensions . AwaitAccessAsync ( cacheKey ) ;
347+ await using var distributedLock = await Extensions . AwaitAccessAsync ( cacheKey ) . ConfigureAwait ( false ) ;
348348
349349 CacheEntry < T > ? cacheEntry ;
350350 if ( distributedLock . IsLockOwner )
351351 {
352352 var oldValue = previousEntry != default ? previousEntry . Value : default ;
353- var refreshedValue = await asyncValueFactory ( oldValue ! ) ;
353+ var refreshedValue = await asyncValueFactory ( oldValue ! ) . ConfigureAwait ( false ) ;
354354 cacheEntry = new CacheEntry < T > ( refreshedValue , settings . TimeToLive ) ;
355355 var cacheUpdateType = entryStatus switch
356356 {
357357 CacheEntryStatus . Miss => CacheUpdateType . AddEntry ,
358358 _ => CacheUpdateType . AddOrUpdateEntry
359359 } ;
360- await InternalSetAsync ( cacheKey , cacheEntry , cacheUpdateType ) ;
360+ await InternalSetAsync ( cacheKey , cacheEntry , cacheUpdateType ) . ConfigureAwait ( false ) ;
361361
362362 KeyLock . ReleaseLock ( cacheKey , cacheEntry ) ;
363363 }
364364 else
365365 {
366- cacheEntry = await GetAsync < T > ( cacheKey ) ;
366+ cacheEntry = await GetAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
367367 }
368368
369369 return cacheEntry ;
@@ -377,15 +377,15 @@ private async ValueTask BackPopulateCacheAsync<T>(int fromIndexExclusive, string
377377 else if ( entryStatus != CacheEntryStatus . Stale )
378378 {
379379 //Last minute check to confirm whether waiting is required
380- var currentEntry = await GetAsync < T > ( cacheKey ) ;
380+ var currentEntry = await GetAsync < T > ( cacheKey ) . ConfigureAwait ( false ) ;
381381 if ( currentEntry != null && currentEntry . GetStaleDate ( settings ) > DateTimeProvider . Now )
382382 {
383383 KeyLock . ReleaseLock ( cacheKey , currentEntry ) ;
384384 return currentEntry ;
385385 }
386386
387387 //Lock until we are notified to be unlocked
388- return await KeyLock . WaitAsync ( cacheKey ) as CacheEntry < T > ;
388+ return await KeyLock . WaitAsync ( cacheKey ) . ConfigureAwait ( false ) as CacheEntry < T > ;
389389 }
390390
391391 return default ;
@@ -410,11 +410,11 @@ public async ValueTask DisposeAsync()
410410 }
411411 else if ( layer is IAsyncDisposable asyncDisposableLayer )
412412 {
413- await asyncDisposableLayer . DisposeAsync ( ) ;
413+ await asyncDisposableLayer . DisposeAsync ( ) . ConfigureAwait ( false ) ;
414414 }
415415 }
416416
417- await Extensions . DisposeAsync ( ) ;
417+ await Extensions . DisposeAsync ( ) . ConfigureAwait ( false ) ;
418418
419419 Disposed = true ;
420420 }
0 commit comments