mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
解决多实例情况下的静态集合缓存问题
This commit is contained in:
parent
922f645249
commit
3c7d67fcc2
@ -19,10 +19,24 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用于解决多实例情况下的静态集合缓存问题
|
||||||
|
/// </summary>
|
||||||
|
public static Func<ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>> ChacheTableEntityFactory = null;
|
||||||
|
private static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> __cacheGetTableByEntity;
|
||||||
public static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity
|
public static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity
|
||||||
{
|
{
|
||||||
get; set;
|
get
|
||||||
} = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>();
|
{
|
||||||
|
|
||||||
|
if (ChacheTableEntityFactory != null)
|
||||||
|
{
|
||||||
|
return ChacheTableEntityFactory.Invoke();
|
||||||
|
}
|
||||||
|
__cacheGetTableByEntity ??= new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>();
|
||||||
|
return __cacheGetTableByEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
internal static void RemoveTableByEntity(Type entity, CommonUtils common)
|
internal static void RemoveTableByEntity(Type entity, CommonUtils common)
|
||||||
{
|
{
|
||||||
if (entity.IsAnonymousType() ||
|
if (entity.IsAnonymousType() ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user