mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
-
This commit is contained in:
parent
d9f04041b8
commit
eb87fbb500
@ -11,7 +11,8 @@ namespace ExtensionsDemo
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var myCache = new SqlSugar.Extensions.HttpRuntimeCache();
|
||||
ICacheService myCache = new SqlSugar.Extensions.HttpRuntimeCache();//ICacheService
|
||||
|
||||
SqlSugarClient db = new SqlSugarClient(
|
||||
new ConnectionConfig()
|
||||
{
|
||||
@ -20,7 +21,7 @@ namespace ExtensionsDemo
|
||||
IsAutoCloseConnection = true,
|
||||
ConfigureExternalServices = new ConfigureExternalServices()
|
||||
{
|
||||
DataInfoCacheService = myCache
|
||||
DataInfoCacheService = myCache //Setting external cache service
|
||||
}
|
||||
});
|
||||
|
||||
@ -35,6 +36,7 @@ namespace ExtensionsDemo
|
||||
JoinType.Left,s1.Id==s2.Id
|
||||
}).Select(s1 => s1).WithCache().ToList();
|
||||
|
||||
|
||||
Console.WriteLine("Cache Key Count:"+myCache.GetAllKey<string>().Count());
|
||||
foreach (var item in myCache.GetAllKey<string>())
|
||||
{
|
||||
|
@ -600,6 +600,7 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||
{
|
||||
Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
|
||||
this.IsCache = true;
|
||||
this.CacheTime = cacheDurationInSeconds;
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user