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