diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs index b925fa625..338a758e1 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs @@ -11,7 +11,7 @@ namespace SqlSugar { Type type = typeof(T); string key = "DataReaderToList." + fields + context.CurrentConnectionConfig.DbType + type.FullName; - IDataReaderEntityBuilder entytyList = context.Utilities.GetCacheInstance().GetOrCreate(key, () => + IDataReaderEntityBuilder entytyList = context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(key, () => { var cacheResult = new IDataReaderEntityBuilder(context, dataReader).CreateBuilder(type); return cacheResult; diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index 0993bdaaa..1b2e636f8 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -41,7 +41,7 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetIsIdentities" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,() => + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,() => { var result = GetColumnInfosByTableName(tableName).Where(it => it.IsIdentity).ToList(); return result.Select(it => it.DbColumnName).ToList(); @@ -51,7 +51,7 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetPrimaries" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,() => + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,() => { var result = GetColumnInfosByTableName(tableName).Where(it => it.IsPrimarykey).ToList(); return result.Select(it => it.DbColumnName).ToList(); @@ -206,7 +206,7 @@ namespace SqlSugar #region Private private List GetListOrCache(string cacheKey, string sql) { - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { var isEnableLogEvent = this.Context.Ado.IsEnableLogEvent; diff --git a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs index 34ea593f4..07c648e84 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs @@ -18,7 +18,7 @@ namespace SqlSugar public EntityInfo GetEntityInfo(Type type) { string cacheKey = "GetEntityInfo" + type.FullName; - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { EntityInfo result = new EntityInfo(); diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs index c8e81578c..b42bb8adc 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs @@ -263,9 +263,9 @@ namespace SqlSugar #endregion #region Cache - public ICacheService GetCacheInstance() + public ICacheService GetReflectionInoCacheInstance() { - return ReflectionInoCache.GetInstance(); + return InstanceFactory.GetReflectionInoCacheInstance(); } public void RemoveCacheAll() diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs index 59123a378..ae0011927 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs @@ -356,13 +356,13 @@ namespace SqlSugar #endregion #region Services - public static ICacheService GetCacheInstance() + public static ICacheService GetReflectionInoCacheInstance() { - return ReflectionInoCache.GetInstance(); + return DefaultServices.ReflectionInoCache; } public static ISerializeService GetSerializeInstance() { - return SerializeService.GetInstance(); + return DefaultServices.Serialize; } #endregion } diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs index cbddbd708..5eeb9bace 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs @@ -98,7 +98,7 @@ namespace SqlSugar public void InitMppingInfo(Type type) { string cacheKey = "Context.InitAttributeMappingTables" + type.FullName; - var entityInfo = this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + var entityInfo = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { var reval = this.Context.EntityMaintenance.GetEntityInfo(type); diff --git a/Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs b/Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs index d8f313e4f..20d38e28f 100644 --- a/Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs +++ b/Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs @@ -8,18 +8,6 @@ namespace SqlSugar { public class ReflectionInoCache : ICacheService { - private static ReflectionInoCache _instance = null; - private static readonly object _instanceLock = new object(); - public static ReflectionInoCache GetInstance() - { - if (_instance == null) - lock (_instanceLock) - if (_instance == null) - { - _instance = new ReflectionInoCache(); - } - return _instance; - } public void Add(string key, V value) { ReflectionInoCache.GetInstance().Add(key,value); diff --git a/Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs b/Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs index 59c5c60e1..cf6ec0a46 100644 --- a/Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs +++ b/Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs @@ -8,17 +8,6 @@ namespace SqlSugar { public class SerializeService:ISerializeService { - private static SerializeService _instance = null; - private static readonly object _instanceLock = new object(); - public static SerializeService GetInstance() { - if (_instance == null) - lock (_instanceLock) - if (_instance == null) - { - _instance = new SerializeService(); - } - return _instance; - } public string SerializeObject(object value) { return JsonConvert.SerializeObject(value); diff --git a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs index 73294f20a..b14676c45 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs @@ -18,7 +18,7 @@ namespace SqlSugar T TranslateCopy(T sourceObject); SqlSugarClient CopyContext(SqlSugarClient context, bool isCopyEvents = false); dynamic DataTableToDynamic(DataTable table); - ICacheService GetCacheInstance(); + ICacheService GetReflectionInoCacheInstance(); void RemoveCacheAll(); void RemoveCacheAll(); void RemoveCache(string key); diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs index cd93f42a9..0b45a33bd 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs @@ -170,7 +170,7 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { string sql = "select * from " + tableName + " WHERE 1=2 "; @@ -207,7 +207,7 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs index 4a8d9a4fe..e52056f60 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs @@ -168,7 +168,7 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { string sql = "select * from " + tableName + " limit 0,1"; @@ -256,7 +256,7 @@ namespace SqlSugar } private List GetListOrCache(string cacheKey, string sql) { - return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey, + return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () => { var isEnableLogEvent = this.Context.Ado.IsEnableLogEvent;