mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
-
This commit is contained in:
@@ -7,12 +7,12 @@ namespace SqlSugar
|
||||
{
|
||||
internal class CacheEngines
|
||||
{
|
||||
public string GetCacheMapping()
|
||||
public static string GetCacheMapping(CacheKey key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetCacheData()
|
||||
public static string GetCacheData(string key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,23 @@ namespace SqlSugar
|
||||
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)
|
||||
{
|
||||
string key = CacheKeyBuider.GetKey(context,queryBuilder).ToString();
|
||||
var result= cacheService.GetOrCreate(key, () => getData(), cacheDurationInSeconds);
|
||||
CacheKey key = CacheKeyBuider.GetKey(context, queryBuilder);
|
||||
var mappingKey = CacheEngines.GetCacheMapping(key);
|
||||
T result = default(T);
|
||||
if (mappingKey.IsNullOrEmpty())
|
||||
result = getData();
|
||||
else
|
||||
{
|
||||
result = cacheService.GetOrCreate("", () => getData(), cacheDurationInSeconds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void RemoveCache(string tableName)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class CacheKey
|
||||
{
|
||||
public new string ToString() {
|
||||
return "";
|
||||
}
|
||||
public string[] Tables { get; set; }
|
||||
public List<string> IdentificationList { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SqlSugar
|
||||
V Get<V>(string key);
|
||||
IEnumerable<string> GetAllKey<V>();
|
||||
void Remove<V>(string key);
|
||||
V GetOrCreate<V>(string cacheKey, Func<V> create,int cacheDurationInSeconds);
|
||||
V GetOrCreate<V>(string cacheKey, Func<V> create,int cacheDurationInSeconds=int.MaxValue);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace SqlSugar
|
||||
return ReflectionInoCore<V>.GetInstance().GetAllKey();
|
||||
}
|
||||
|
||||
public V GetOrCreate<V>(string cacheKey, Func<V> create)
|
||||
public V GetOrCreate<V>(string cacheKey, Func<V> create,int cacheDurationInSeconds=int.MaxValue)
|
||||
{
|
||||
return ReflectionInoCore<V>.GetInstance().GetOrCreate(cacheKey, create);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user