mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 18:51:28 +08:00
10.10.12
This commit is contained in:
@@ -113,7 +113,7 @@ namespace ThingsGateway.SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly HttpClient client = new HttpClient();
|
||||
private static readonly HttpClient client = new HttpClient();
|
||||
|
||||
/// <summary>
|
||||
/// 异步批量快速插入数据
|
||||
|
@@ -8,6 +8,6 @@
|
||||
V Get<V>(string key);
|
||||
IEnumerable<string> GetAllKey<V>();
|
||||
void Remove<V>(string key);
|
||||
V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue);
|
||||
V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = 3600);
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ namespace ThingsGateway.SqlSugar
|
||||
return ReflectionInoCore<V>.GetInstance().GetAllKey();
|
||||
}
|
||||
|
||||
public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
|
||||
public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = 3600)
|
||||
{
|
||||
return ReflectionInoCore<V>.GetInstance().GetOrCreate(cacheKey, create);
|
||||
}
|
||||
@@ -43,10 +43,13 @@ namespace ThingsGateway.SqlSugar
|
||||
}
|
||||
public class ReflectionInoCore<V>
|
||||
{
|
||||
private MemoryCache InstanceCache => new MemoryCache() { Expire = 60 };
|
||||
private MemoryCache InstanceCache = new MemoryCache() { Expire = 180 };
|
||||
private static ReflectionInoCore<V> _instance = null;
|
||||
private static readonly object _instanceLock = new object();
|
||||
private ReflectionInoCore() { }
|
||||
private ReflectionInoCore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public V this[string key]
|
||||
{
|
||||
@@ -107,10 +110,10 @@ namespace ThingsGateway.SqlSugar
|
||||
return this.InstanceCache.Keys;
|
||||
}
|
||||
|
||||
public V GetOrCreate(string cacheKey, Func<V> create)
|
||||
public V GetOrCreate(string cacheKey, Func<V> create, int expire = 3600)
|
||||
{
|
||||
return InstanceCache.GetOrAdd<V>(cacheKey, (a) =>
|
||||
create());
|
||||
create(), expire);
|
||||
}
|
||||
}
|
||||
public static class ReflectionInoHelper
|
||||
|
@@ -447,6 +447,28 @@ namespace ThingsGateway.SqlSugar
|
||||
}
|
||||
|
||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(tableName)) return new List<DbColumnInfo>();
|
||||
string cacheKey = "QuestDB.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower() + this.Context.CurrentConnectionConfig.ConfigId;
|
||||
cacheKey = GetCacheKey(cacheKey);
|
||||
|
||||
if (isCache)
|
||||
{
|
||||
|
||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () =>
|
||||
{
|
||||
return GetColInfo(tableName);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetColInfo(tableName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<DbColumnInfo> GetColInfo(string tableName)
|
||||
{
|
||||
var sql = String.Format(GetColumnInfosByTableNameSql, tableName);
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
|
@@ -717,8 +717,32 @@ namespace ThingsGateway.SqlSugar
|
||||
/// <returns>列信息列表</returns>
|
||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
||||
{
|
||||
var sql = $"select * from {this.SqlBuilder.GetTranslationColumnName(tableName)} where 1=2 ";
|
||||
|
||||
if (string.IsNullOrEmpty(tableName)) return new List<DbColumnInfo>();
|
||||
string cacheKey = "TDengine.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower() + this.Context.CurrentConnectionConfig.ConfigId;
|
||||
cacheKey = GetCacheKey(cacheKey);
|
||||
|
||||
if (isCache)
|
||||
{
|
||||
|
||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () =>
|
||||
{
|
||||
return GetColInfo(tableName);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetColInfo(tableName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<DbColumnInfo> GetColInfo(string tableName)
|
||||
{
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
|
||||
var sql = $"select * from {this.SqlBuilder.GetTranslationColumnName(tableName)} where 1=2 ";
|
||||
DataTable dt = null;
|
||||
try
|
||||
{
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.10.8</PluginVersion>
|
||||
<ProPluginVersion>10.10.7</ProPluginVersion>
|
||||
<DefaultVersion>10.10.11</DefaultVersion>
|
||||
<PluginVersion>10.10.9</PluginVersion>
|
||||
<ProPluginVersion>10.10.9</ProPluginVersion>
|
||||
<DefaultVersion>10.10.12</DefaultVersion>
|
||||
<AuthenticationVersion>10.10.1</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.10.1</SourceGeneratorVersion>
|
||||
<NET8Version>8.0.19</NET8Version>
|
||||
|
Reference in New Issue
Block a user