Add Remove Cache All

This commit is contained in:
sunkaixuan
2017-07-03 00:48:19 +08:00
parent 0abd9241c6
commit 50fc79296b

View File

@@ -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);
}
}
}
}
}