@@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.OutputCaching.Memory;
1010internal sealed class MemoryOutputCacheStore : IOutputCacheStore
1111{
1212 private readonly MemoryCache _cache ;
13- private readonly Dictionary < string , HashSet < ( string key , Guid entryId ) > > _taggedEntries = [ ] ;
13+ private readonly Dictionary < string , HashSet < ( string Key , Guid EntryId ) > > _taggedEntries = [ ] ;
1414 private readonly object _tagsLock = new ( ) ;
1515
1616 internal MemoryOutputCacheStore ( MemoryCache cache )
@@ -21,7 +21,7 @@ internal MemoryOutputCacheStore(MemoryCache cache)
2121 }
2222
2323 // For testing
24- internal Dictionary < string , HashSet < string > > TaggedEntries => _taggedEntries . ToDictionary ( kvp => kvp . Key , kvp => kvp . Value . Select ( t => t . key ) . ToHashSet ( ) ) ;
24+ internal Dictionary < string , HashSet < string > > TaggedEntries => _taggedEntries . ToDictionary ( kvp => kvp . Key , kvp => kvp . Value . Select ( t => t . Key ) . ToHashSet ( ) ) ;
2525
2626 public ValueTask EvictByTagAsync ( string tag , CancellationToken cancellationToken )
2727 {
@@ -31,7 +31,7 @@ public ValueTask EvictByTagAsync(string tag, CancellationToken cancellationToken
3131 {
3232 if ( _taggedEntries . TryGetValue ( tag , out var keys ) )
3333 {
34- if ( keys != null && keys . Count > 0 )
34+ if ( keys is { Count : > 0 } )
3535 {
3636 // If MemoryCache changed to run eviction callbacks inline in Remove, iterating over keys could throw
3737 // To prevent allocating a copy of the keys we check if the eviction callback ran,
@@ -41,9 +41,9 @@ public ValueTask EvictByTagAsync(string tag, CancellationToken cancellationToken
4141 while ( i > 0 )
4242 {
4343 var oldCount = keys . Count ;
44- foreach ( var tuple in keys )
44+ foreach ( var ( key , _ ) in keys )
4545 {
46- _cache . Remove ( tuple . key ) ;
46+ _cache . Remove ( key ) ;
4747 i -- ;
4848 if ( oldCount != keys . Count )
4949 {
@@ -99,7 +99,7 @@ public ValueTask SetAsync(string key, byte[] value, string[]? tags, TimeSpan val
9999
100100 Debug . Assert ( keys != null ) ;
101101
102- keys . Add ( ValueTuple . Create ( key , entryId ) ) ;
102+ keys . Add ( ( key , entryId ) ) ;
103103 }
104104
105105 SetEntry ( key , value , tags , validFor , entryId ) ;
@@ -126,17 +126,17 @@ private void SetEntry(string key, byte[] value, string[]? tags, TimeSpan validFo
126126 if ( tags is { Length : > 0 } )
127127 {
128128 // Remove cache keys from tag lists when the entry is evicted
129- options . RegisterPostEvictionCallback ( RemoveFromTags , ValueTuple . Create ( tags , entryId ) ) ;
129+ options . RegisterPostEvictionCallback ( RemoveFromTags , ( tags , entryId ) ) ;
130130 }
131131
132132 _cache . Set ( key , value , options ) ;
133133 }
134134
135- void RemoveFromTags ( object key , object ? value , EvictionReason reason , object ? state )
135+ private void RemoveFromTags ( object key , object ? value , EvictionReason reason , object ? state )
136136 {
137137 Debug . Assert ( state != null ) ;
138138
139- var ( tags , entryId ) = ( ( string [ ] tags , Guid entryId ) ) state ;
139+ var ( tags , entryId ) = ( ( string [ ] Tags , Guid EntryId ) ) state ;
140140
141141 Debug . Assert ( tags != null ) ;
142142 Debug . Assert ( tags . Length > 0 ) ;
@@ -149,7 +149,7 @@ void RemoveFromTags(object key, object? value, EvictionReason reason, object? st
149149 {
150150 if ( _taggedEntries . TryGetValue ( tag , out var tagged ) )
151151 {
152- tagged . Remove ( ( key : ( string ) key , entryId ) ) ;
152+ tagged . Remove ( ( Key : ( string ) key , entryId ) ) ;
153153
154154 // Remove the collection if there is no more keys in it
155155 if ( tagged . Count == 0 )
0 commit comments