|
@ -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; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|