mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Add Config DefaultCacheDurationInSeconds
This commit is contained in:
@@ -778,13 +778,16 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
|
Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (isCache)
|
if (isCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -1631,6 +1634,15 @@ namespace SqlSugar
|
|||||||
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
||||||
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||||
}
|
}
|
||||||
|
protected int SetCacheTime(int cacheDurationInSeconds)
|
||||||
|
{
|
||||||
|
if (cacheDurationInSeconds == int.MaxValue && this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DefaultCacheDurationInSeconds > 0)
|
||||||
|
{
|
||||||
|
cacheDurationInSeconds = this.Context.CurrentConnectionConfig.MoreSettings.DefaultCacheDurationInSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheDurationInSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1912,12 +1924,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (isCache)
|
if (isCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -2281,12 +2295,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -2708,12 +2724,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3062,12 +3080,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3447,12 +3467,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3863,12 +3885,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -4312,12 +4336,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -4710,12 +4736,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -5119,12 +5147,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -5552,12 +5582,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -6011,12 +6043,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
|
@@ -13,5 +13,6 @@ namespace SqlSugar
|
|||||||
/// Some MYSQL databases do not support NVarchar set true
|
/// Some MYSQL databases do not support NVarchar set true
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool MySqlDisableNarvchar { get; set; }
|
public bool MySqlDisableNarvchar { get; set; }
|
||||||
|
public int DefaultCacheDurationInSeconds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user