mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Add Remove Cache All
This commit is contained in:
@@ -39,7 +39,10 @@ namespace SqlSugar
|
||||
if (_instance == null)
|
||||
lock (_instanceLock)
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new CacheManager<V>();
|
||||
CacheManager.Add(_instance.InstanceCache);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
@@ -84,4 +87,23 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class CacheManager
|
||||
{
|
||||
private static List<object> CacheObjects = new List<object>();
|
||||
internal static void Add(object CacheObject)
|
||||
{
|
||||
CacheObjects.Add(CacheObject);
|
||||
}
|
||||
|
||||
public static void RemoveAllCache()
|
||||
{
|
||||
lock (CacheObjects)
|
||||
{
|
||||
for (int i = 0; i < CacheObjects.Count; i++)
|
||||
{
|
||||
CacheObjects[i] = Activator.CreateInstance(CacheObjects[i].GetType(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user