Skip to content

Commit ba15ee2

Browse files
authored
Bump to Microsoft.Extensions.Caching.Memory to 6.0.3 for netfx (#3004)
* Bump to 6.0.3 * Remove private reflection.
1 parent 4052186 commit ba15ee2

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CertificateUtility.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -308,25 +308,12 @@ public static void ChangeServerTceSetting(bool fEnable, SqlConnectionStringBuild
308308

309309
private static void ClearCache(MemoryCache cache)
310310
{
311-
// Get the Clear method of the cache and use it if available. This is available in Microsoft.Extensions.Caching 8.0
312-
MethodInfo clearMethod = cache.GetType().GetMethod("Clear", BindingFlags.Instance | BindingFlags.Public);
313-
if (clearMethod != null)
314-
{
315-
clearMethod.Invoke(cache, null);
316-
}
317-
else
318-
{
319-
// Otherwise, use the Remove function to remove all entries using all keys in the cache gathered using reflection.
320-
PropertyInfo cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
321-
ICollection cacheEntriesCollection = (ICollection)cacheEntriesCollectionDefinition.GetValue(cache);
322-
List<ICacheEntry> cacheCollectionValues = new List<ICacheEntry>();
323-
324-
foreach (object cacheItem in cacheEntriesCollection)
325-
{
326-
ICacheEntry cacheItemValue = (ICacheEntry)cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null);
327-
cache.Remove(cacheItemValue.Key);
328-
}
329-
}
311+
#if NET
312+
cache.Clear();
313+
#else
314+
// Compact with a target of 100% of objects is equivalent to clearing the cache
315+
cache.Compact(1);
316+
#endif
330317
}
331318
}
332319
}

tools/props/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<!-- NetFx and NetCore project dependencies -->
3232
<PropertyGroup>
3333
<AzureIdentityVersion>1.11.4</AzureIdentityVersion>
34-
<MicrosoftExtensionsCachingMemoryVersion>6.0.1</MicrosoftExtensionsCachingMemoryVersion>
34+
<MicrosoftExtensionsCachingMemoryVersion>6.0.3</MicrosoftExtensionsCachingMemoryVersion>
3535
<MicrosoftIdentityModelJsonWebTokensVersion>7.5.0</MicrosoftIdentityModelJsonWebTokensVersion>
3636
<MicrosoftIdentityModelProtocolsOpenIdConnectVersion>7.5.0</MicrosoftIdentityModelProtocolsOpenIdConnectVersion>
3737
<SystemTextJsonVersion>6.0.10</SystemTextJsonVersion>

0 commit comments

Comments
 (0)