diff --git a/Falcon.SugarApi/DatabaseDefinitions/Cache/SqlSugarRedisCache.cs b/Falcon.SugarApi/DatabaseDefinitions/Cache/SqlSugarRedisCache.cs
index e065b9a..552a77e 100644
--- a/Falcon.SugarApi/DatabaseDefinitions/Cache/SqlSugarRedisCache.cs
+++ b/Falcon.SugarApi/DatabaseDefinitions/Cache/SqlSugarRedisCache.cs
@@ -21,6 +21,11 @@ namespace Falcon.SugarApi.DatabaseDefinitions.Cache
///
public static SugarRedisClient Service { get; private set; } = null;
+ ///
+ /// 默认缓冲时间
+ ///
+ public const int DefaultcacheDurationInSeconds = 24 * 60 * 60;
+
///
/// 通过配置实现Redis缓冲,必须单例实现.
/// 默认:127.0.0.1:6379,password=,connectTimeout=3000,connectRetry=1,syncTimeout=10000,DefaultDatabase=0
@@ -43,7 +48,8 @@ namespace Falcon.SugarApi.DatabaseDefinitions.Cache
}
public void Add(string key, V value, int cacheDurationInSeconds) {
- Service.Set(key, value, cacheDurationInSeconds);
+ cacheDurationInSeconds = Math.Min(cacheDurationInSeconds, DefaultcacheDurationInSeconds);
+ Service.Set(key, value, cacheDurationInSeconds / 60);
}
public bool ContainsKey(string key) {
@@ -59,7 +65,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions.Cache
return Service.SearchCacheRegex("SqlSugarDataCache.*");
}
- public V GetOrCreate(string cacheKey, Func create, int cacheDurationInSeconds = int.MaxValue) {
+ public V GetOrCreate(string cacheKey, Func create, int cacheDurationInSeconds = DefaultcacheDurationInSeconds) {
if (ContainsKey(cacheKey)) {
var result = Get(cacheKey);
if (result == null) {