@@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.OutputCaching.Memory;
10
10
internal sealed class MemoryOutputCacheStore : IOutputCacheStore
11
11
{
12
12
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 = [ ] ;
14
14
private readonly object _tagsLock = new ( ) ;
15
15
16
16
internal MemoryOutputCacheStore ( MemoryCache cache )
@@ -21,7 +21,7 @@ internal MemoryOutputCacheStore(MemoryCache cache)
21
21
}
22
22
23
23
// 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 ( ) ) ;
25
25
26
26
public ValueTask EvictByTagAsync ( string tag , CancellationToken cancellationToken )
27
27
{
@@ -31,7 +31,7 @@ public ValueTask EvictByTagAsync(string tag, CancellationToken cancellationToken
31
31
{
32
32
if ( _taggedEntries . TryGetValue ( tag , out var keys ) )
33
33
{
34
- if ( keys != null && keys . Count > 0 )
34
+ if ( keys is { Count : > 0 } )
35
35
{
36
36
// If MemoryCache changed to run eviction callbacks inline in Remove, iterating over keys could throw
37
37
// 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
41
41
while ( i > 0 )
42
42
{
43
43
var oldCount = keys . Count ;
44
- foreach ( var tuple in keys )
44
+ foreach ( var ( key , _ ) in keys )
45
45
{
46
- _cache . Remove ( tuple . key ) ;
46
+ _cache . Remove ( key ) ;
47
47
i -- ;
48
48
if ( oldCount != keys . Count )
49
49
{
@@ -99,7 +99,7 @@ public ValueTask SetAsync(string key, byte[] value, string[]? tags, TimeSpan val
99
99
100
100
Debug . Assert ( keys != null ) ;
101
101
102
- keys . Add ( ValueTuple . Create ( key , entryId ) ) ;
102
+ keys . Add ( ( key , entryId ) ) ;
103
103
}
104
104
105
105
SetEntry ( key , value , tags , validFor , entryId ) ;
@@ -126,17 +126,17 @@ private void SetEntry(string key, byte[] value, string[]? tags, TimeSpan validFo
126
126
if ( tags is { Length : > 0 } )
127
127
{
128
128
// 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 ) ) ;
130
130
}
131
131
132
132
_cache . Set ( key , value , options ) ;
133
133
}
134
134
135
- void RemoveFromTags ( object key , object ? value , EvictionReason reason , object ? state )
135
+ private void RemoveFromTags ( object key , object ? value , EvictionReason reason , object ? state )
136
136
{
137
137
Debug . Assert ( state != null ) ;
138
138
139
- var ( tags , entryId ) = ( ( string [ ] tags , Guid entryId ) ) state ;
139
+ var ( tags , entryId ) = ( ( string [ ] Tags , Guid EntryId ) ) state ;
140
140
141
141
Debug . Assert ( tags != null ) ;
142
142
Debug . Assert ( tags . Length > 0 ) ;
@@ -149,7 +149,7 @@ void RemoveFromTags(object key, object? value, EvictionReason reason, object? st
149
149
{
150
150
if ( _taggedEntries . TryGetValue ( tag , out var tagged ) )
151
151
{
152
- tagged . Remove ( ( key : ( string ) key , entryId ) ) ;
152
+ tagged . Remove ( ( Key : ( string ) key , entryId ) ) ;
153
153
154
154
// Remove the collection if there is no more keys in it
155
155
if ( tagged . Count == 0 )
0 commit comments