Bump to Microsoft.Extensions.Caching.Memory to 6.0.3 for netfx (#3004)
* Bump to 6.0.3 * Remove private reflection.
This commit is contained in:
Родитель
4052186ac6
Коммит
ba15ee2baf
|
@ -308,25 +308,12 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
|
||||
private static void ClearCache(MemoryCache cache)
|
||||
{
|
||||
// Get the Clear method of the cache and use it if available. This is available in Microsoft.Extensions.Caching 8.0
|
||||
MethodInfo clearMethod = cache.GetType().GetMethod("Clear", BindingFlags.Instance | BindingFlags.Public);
|
||||
if (clearMethod != null)
|
||||
{
|
||||
clearMethod.Invoke(cache, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, use the Remove function to remove all entries using all keys in the cache gathered using reflection.
|
||||
PropertyInfo cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
ICollection cacheEntriesCollection = (ICollection)cacheEntriesCollectionDefinition.GetValue(cache);
|
||||
List<ICacheEntry> cacheCollectionValues = new List<ICacheEntry>();
|
||||
|
||||
foreach (object cacheItem in cacheEntriesCollection)
|
||||
{
|
||||
ICacheEntry cacheItemValue = (ICacheEntry)cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null);
|
||||
cache.Remove(cacheItemValue.Key);
|
||||
}
|
||||
}
|
||||
#if NET
|
||||
cache.Clear();
|
||||
#else
|
||||
// Compact with a target of 100% of objects is equivalent to clearing the cache
|
||||
cache.Compact(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<!-- NetFx and NetCore project dependencies -->
|
||||
<PropertyGroup>
|
||||
<AzureIdentityVersion>1.11.4</AzureIdentityVersion>
|
||||
<MicrosoftExtensionsCachingMemoryVersion>6.0.1</MicrosoftExtensionsCachingMemoryVersion>
|
||||
<MicrosoftExtensionsCachingMemoryVersion>6.0.3</MicrosoftExtensionsCachingMemoryVersion>
|
||||
<MicrosoftIdentityModelJsonWebTokensVersion>7.5.0</MicrosoftIdentityModelJsonWebTokensVersion>
|
||||
<MicrosoftIdentityModelProtocolsOpenIdConnectVersion>7.5.0</MicrosoftIdentityModelProtocolsOpenIdConnectVersion>
|
||||
<SystemTextJsonVersion>6.0.10</SystemTextJsonVersion>
|
||||
|
|
Загрузка…
Ссылка в новой задаче