File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
src/BootstrapBlazor.Server/Extensions Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,13 @@ public static string GetExpiration(this ICacheEntry entry)
2727 }
2828 else if ( entry . SlidingExpiration . HasValue )
2929 {
30- ret = $ "Sliding: { entry . GetSlidingLeftTime ( ) . TotalSeconds : ###} /{ entry . SlidingExpiration . Value . TotalSeconds } ";
30+ var ts = entry . GetSlidingLeftTime ( ) ;
31+ ret = ts == TimeSpan . Zero ? "Expirated" : $ "Sliding: { ts . TotalSeconds : ###} /{ entry . SlidingExpiration . Value . TotalSeconds } ";
3132 }
3233 else if ( entry . AbsoluteExpiration . HasValue )
3334 {
34- ret = $ "Absolute: { entry . AbsoluteExpiration . Value } ";
35+ var ts = entry . GetAbsoluteLeftTime ( ) ;
36+ ret = ts == TimeSpan . Zero ? "Expirated" : $ "Absolute: { ts . TotalSeconds : ###} ";
3537 }
3638 else if ( entry . ExpirationTokens . Count != 0 )
3739 {
@@ -59,4 +61,14 @@ private static TimeSpan GetSlidingLeftTime(this ICacheEntry entry)
5961 }
6062 return ts ;
6163 }
64+
65+ private static TimeSpan GetAbsoluteLeftTime ( this ICacheEntry entry )
66+ {
67+ var ts = entry . AbsoluteExpiration ! . Value - DateTimeOffset . UtcNow ;
68+ if ( ts < TimeSpan . Zero )
69+ {
70+ ts = TimeSpan . Zero ;
71+ }
72+ return ts ;
73+ }
6274}
You can’t perform that action at this time.
0 commit comments