File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ object CacheFactory(ICacheEntry entry) =>
93
93
new Lazy < T > ( ( ) =>
94
94
{
95
95
var result = addItemFactory ( entry ) ;
96
+ SetAbsoluteExpirationFromRelative ( entry ) ;
96
97
EnsureEvictionCallbackDoesNotReturnTheAsyncOrLazy < T > ( entry . PostEvictionCallbacks ) ;
97
98
return result ;
98
99
} ) ;
@@ -136,6 +137,15 @@ object CacheFactory(ICacheEntry entry) =>
136
137
}
137
138
}
138
139
140
+ private static void SetAbsoluteExpirationFromRelative ( ICacheEntry entry )
141
+ {
142
+ if ( ! entry . AbsoluteExpirationRelativeToNow . HasValue ) return ;
143
+
144
+ var absoluteExpiration = DateTimeOffset . UtcNow + entry . AbsoluteExpirationRelativeToNow . Value ;
145
+ if ( ! entry . AbsoluteExpiration . HasValue || absoluteExpiration < entry . AbsoluteExpiration )
146
+ entry . AbsoluteExpiration = absoluteExpiration ;
147
+ }
148
+
139
149
public virtual void Remove ( string key )
140
150
{
141
151
ValidateKey ( key ) ;
@@ -163,6 +173,7 @@ object CacheFactory(ICacheEntry entry) =>
163
173
new AsyncLazy < T > ( ( ) =>
164
174
{
165
175
var result = addItemFactory ( entry ) ;
176
+ SetAbsoluteExpirationFromRelative ( entry ) ;
166
177
EnsureEvictionCallbackDoesNotReturnTheAsyncOrLazy < T > ( entry . PostEvictionCallbacks ) ;
167
178
return result ;
168
179
} ) ;
Original file line number Diff line number Diff line change 1
1
# Release notes for LazyCache #
2
2
3
+ ## Version 2.0.5
4
+ - Fix #85 and #100 Absolute expiration not working with TimeSpan. Thank you to @Meberem and @Sinhk .
5
+ - Fix #124 casing for PackageReference - by @jnyrup
6
+
3
7
## Version 2.0.4
4
8
- Fix #82 Make constructor resolution specific when using aspnet core dependency injection
5
9
You can’t perform that action at this time.
0 commit comments