mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
-
This commit is contained in:
@@ -7,14 +7,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
internal class CacheEngines
|
internal class CacheEngines
|
||||||
{
|
{
|
||||||
public static string GetCacheMapping(CacheKey key)
|
static string CacheMappingKey = "SqlSugarDataCacheMapping";
|
||||||
|
public static string GetCacheMapping(string tableName)
|
||||||
{
|
{
|
||||||
return null;
|
return CacheMappingKey+ UtilConstants.Dot+tableName+ UtilConstants.Dot + Guid.NewGuid();
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetCacheData(string key)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,21 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public static CacheKey GetKey(SqlSugarClient context, QueryBuilder queryBuilder)
|
public static CacheKey GetKey(SqlSugarClient context, QueryBuilder queryBuilder)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CacheKey result = new CacheKey();
|
||||||
|
result.Database = context.Context.Ado.Connection.Database;
|
||||||
|
result.Tables = new List<string>();
|
||||||
|
result.Tables.Add(context.EntityMaintenance.GetTableName(queryBuilder.EntityName));
|
||||||
|
result.Tables.AddRange(queryBuilder.JoinQueryInfos.Select(it=>it.TableName));
|
||||||
|
result.IdentificationList = new List<string>();
|
||||||
|
result.IdentificationList.Add(queryBuilder.GetTableNameString);
|
||||||
|
result.IdentificationList.Add(queryBuilder.GetJoinValueString);
|
||||||
|
result.IdentificationList.Add(queryBuilder.GetOrderByString);
|
||||||
|
result.IdentificationList.Add(queryBuilder.GetGroupByString);
|
||||||
|
result.IdentificationList.Add(queryBuilder.GetWhereValueString);
|
||||||
|
result.IdentificationList.Add(queryBuilder.PartitionByValue);
|
||||||
|
result.IdentificationList.Add(queryBuilder.Take.ObjToString());
|
||||||
|
result.IdentificationList.Add(queryBuilder.Skip.ObjToString());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,18 +7,24 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
internal class CacheSchemeMain
|
internal class CacheSchemeMain
|
||||||
{
|
{
|
||||||
|
|
||||||
public static T GetOrCreate<T>(ICacheService cacheService, QueryBuilder queryBuilder, Func<T> getData, int cacheDurationInSeconds, SqlSugarClient context)
|
public static T GetOrCreate<T>(ICacheService cacheService, QueryBuilder queryBuilder, Func<T> getData, int cacheDurationInSeconds, SqlSugarClient context)
|
||||||
{
|
{
|
||||||
CacheKey key = CacheKeyBuider.GetKey(context, queryBuilder);
|
CacheKey key = CacheKeyBuider.GetKey(context, queryBuilder);
|
||||||
var mappingKey = CacheEngines.GetCacheMapping(key);
|
string keyString = key.ToString();
|
||||||
T result = default(T);
|
foreach (var tableName in key.Tables)
|
||||||
if (mappingKey.IsNullOrEmpty())
|
|
||||||
result = getData();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
result = cacheService.GetOrCreate("", () => getData(), cacheDurationInSeconds);
|
//if (!mappingInfo.Any(it=>it.Key.Equals(tableName,StringComparison.CurrentCultureIgnoreCase))) {
|
||||||
|
// cacheService.Add<>(new KeyValuePair<string,string>(tableName, keyString));
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T result = default(T);
|
||||||
|
//if (mappingKey.IsNullOrEmpty())
|
||||||
|
// result = getData();
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// result = cacheService.GetOrCreate("", () => getData(), cacheDurationInSeconds);
|
||||||
|
//}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class CacheKey
|
public class CacheKey
|
||||||
{
|
{
|
||||||
public string[] Tables { get; set; }
|
public string Database { get; set; }
|
||||||
|
public List<string> Tables { get; set; }
|
||||||
public List<string> IdentificationList { get; set; }
|
public List<string> IdentificationList { get; set; }
|
||||||
|
public new string ToString()
|
||||||
|
{
|
||||||
|
return "SqlSugarDataCache." + UtilConstants.Dot + string.Join(UtilConstants.Dot, this.Tables) + string.Join(UtilConstants.Dot, this.IdentificationList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user