@@ -90,22 +90,22 @@ private void StartPool()
9090
9191 public void Add ( string key , object value , int cacheSeconds )
9292 {
93- Store ( StoreMode . Add , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
93+ Store ( StoreMode . Add , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
9494 }
9595
9696 public async Task AddAsync ( string key , object value , int cacheSeconds )
9797 {
98- await StoreAsync ( StoreMode . Add , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
98+ await StoreAsync ( StoreMode . Add , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
9999 }
100100
101101 public void Set ( string key , object value , int cacheSeconds )
102102 {
103- Store ( StoreMode . Set , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
103+ Store ( StoreMode . Set , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
104104 }
105105
106106 public async Task SetAsync ( string key , object value , int cacheSeconds )
107107 {
108- await StoreAsync ( StoreMode . Set , key , value , new TimeSpan ( 0 , 0 , cacheSeconds ) ) ;
108+ await StoreAsync ( StoreMode . Set , key , value , TimeSpan . FromSeconds ( cacheSeconds ) ) ;
109109 }
110110
111111 /// <summary>
@@ -1161,6 +1161,11 @@ protected static uint GetExpiration(
11611161 // infinity
11621162 if ( validFor == TimeSpan . Zero || validFor == TimeSpan . MaxValue ) return 0 ;
11631163
1164+ if ( validFor . Value . TotalSeconds <= MaxSeconds )
1165+ {
1166+ return ( uint ) validFor . Value . TotalSeconds ;
1167+ }
1168+
11641169 expiresAt = DateTime . Now . Add ( validFor . Value ) ;
11651170 }
11661171
0 commit comments