【优化】优化内存缓存【获取所有缓存键】使用方法。

This commit is contained in:
jianweie code
2024-01-15 22:24:43 +08:00
parent d23c0cde84
commit f16797adb5

View File

@@ -268,7 +268,10 @@ namespace CoreCms.Net.Caching.SqlSugar
public List<string> GetCacheKeys()
{
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
var entries = Cache.GetType().GetField("_entries", flags).GetValue(Cache);
var coherentState = Cache.GetType().GetField("_coherentState", flags).GetValue(Cache);
var entries = coherentState.GetType().GetField("_entries", flags).GetValue(coherentState);
var cacheItems = entries as IDictionary;
var keys = new List<string>();
if (cacheItems == null) return keys;