@@ -32,25 +32,25 @@ public class ImageSharpMiddleware
3232 /// The write worker used for limiting identical requests.
3333 /// </summary>
3434 private static readonly ConcurrentDictionary < string , Task < ImageWorkerResult > > WriteWorkers
35- = new ConcurrentDictionary < string , Task < ImageWorkerResult > > ( StringComparer . OrdinalIgnoreCase ) ;
35+ = new ( StringComparer . OrdinalIgnoreCase ) ;
3636
3737 /// <summary>
3838 /// The read worker used for limiting identical requests.
3939 /// </summary>
4040 private static readonly ConcurrentDictionary < string , Task < ImageWorkerResult > > ReadWorkers
41- = new ConcurrentDictionary < string , Task < ImageWorkerResult > > ( StringComparer . OrdinalIgnoreCase ) ;
41+ = new ( StringComparer . OrdinalIgnoreCase ) ;
4242
4343 /// <summary>
4444 /// Used to temporarily store source metadata reads to reduce the overhead of cache lookups.
4545 /// </summary>
4646 private static readonly ConcurrentTLruCache < string , ImageMetadata > SourceMetadataLru
47- = new ConcurrentTLruCache < string , ImageMetadata > ( 1024 , TimeSpan . FromMinutes ( 5 ) ) ;
47+ = new ( 1024 , TimeSpan . FromMinutes ( 5 ) ) ;
4848
4949 /// <summary>
5050 /// Used to temporarily store cache resolver reads to reduce the overhead of cache lookups.
5151 /// </summary>
52- private static readonly ConcurrentTLruCache < string , ValueTuple < IImageCacheResolver , ImageCacheMetadata > > CacheResolverLru
53- = new ConcurrentTLruCache < string , ValueTuple < IImageCacheResolver , ImageCacheMetadata > > ( 1024 , TimeSpan . FromMinutes ( 5 ) ) ;
52+ private static readonly ConcurrentTLruCache < string , ( IImageCacheResolver , ImageCacheMetadata ) > CacheResolverLru
53+ = new ( 1024 , TimeSpan . FromMinutes ( 5 ) ) ;
5454
5555 /// <summary>
5656 /// The function processing the Http request.
@@ -274,7 +274,7 @@ private async Task ProcessRequestAsync(
274274 ImageWorkerResult readResult = default ;
275275 try
276276 {
277- readResult = await this . IsNewOrUpdatedAsync ( sourceImageResolver , imageContext , key ) ;
277+ readResult = await this . IsNewOrUpdatedAsync ( sourceImageResolver , key ) ;
278278 }
279279 finally
280280 {
@@ -288,7 +288,7 @@ private async Task ProcessRequestAsync(
288288 }
289289
290290 // Not cached, or is updated? Let's get it from the image resolver.
291- var sourceImageMetadata = readResult . SourceImageMetadata ;
291+ ImageMetadata sourceImageMetadata = readResult . SourceImageMetadata ;
292292
293293 // Enter an asynchronous write worker which prevents multiple writes and delays any reads for the same request.
294294 // This reduces the overheads of unnecessary processing.
@@ -433,7 +433,6 @@ private ValueTask StreamDisposeAsync(Stream stream)
433433
434434 private async Task < ImageWorkerResult > IsNewOrUpdatedAsync (
435435 IImageResolver sourceImageResolver ,
436- ImageContext imageContext ,
437436 string key )
438437 {
439438 // Pause until the write has been completed.
@@ -514,7 +513,7 @@ private async Task SendResponseAsync(
514513 this . logger . LogImageServed ( imageContext . GetDisplayUrl ( ) , key ) ;
515514
516515 // When stream is null we're sending from the cache.
517- using ( var stream = await cacheResolver . OpenReadAsync ( ) )
516+ using ( Stream stream = await cacheResolver . OpenReadAsync ( ) )
518517 {
519518 await imageContext . SendAsync ( stream , metadata ) ;
520519 }
0 commit comments