@@ -90,22 +90,22 @@ private void StartPool()
90
90
91
91
public void Add ( string key , object value , int cacheSeconds )
92
92
{
93
- Store ( StoreMode . Add , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
93
+ Store ( StoreMode . Add , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
94
94
}
95
95
96
96
public async Task AddAsync ( string key , object value , int cacheSeconds )
97
97
{
98
- await StoreAsync ( StoreMode . Add , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
98
+ await StoreAsync ( StoreMode . Add , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
99
99
}
100
100
101
101
public void Set ( string key , object value , int cacheSeconds )
102
102
{
103
- Store ( StoreMode . Set , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
103
+ Store ( StoreMode . Set , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
104
104
}
105
105
106
106
public async Task SetAsync ( string key , object value , int cacheSeconds )
107
107
{
108
- await StoreAsync ( StoreMode . Set , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
108
+ await StoreAsync ( StoreMode . Set , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
109
109
}
110
110
111
111
/// <summary>
@@ -1161,6 +1161,11 @@ protected static uint GetExpiration(
1161
1161
// infinity
1162
1162
if ( validFor == TimeSpan . Zero || validFor == TimeSpan . MaxValue ) return 0 ;
1163
1163
1164
+ if ( validFor . Value . TotalSeconds <= MaxSeconds )
1165
+ {
1166
+ return ( uint ) validFor . Value . TotalSeconds ;
1167
+ }
1168
+
1164
1169
expiresAt = DateTime . Now . Add ( validFor . Value ) ;
1165
1170
}
1166
1171
0 commit comments