@@ -30,6 +30,9 @@ internal class CacheManager : ICacheManager
3030 [ NotNull ]
3131 private static CacheManager ? Instance { get ; set ; }
3232
33+ [ NotNull ]
34+ private static BootstrapBlazorOptions ? Options { get ; set ; }
35+
3336 private const string CacheKeyPrefix = "BootstrapBlazor" ;
3437
3538 /// <summary>
@@ -42,6 +45,7 @@ public CacheManager(IServiceProvider provider, IMemoryCache memoryCache)
4245 Provider = provider ;
4346 Cache = memoryCache ;
4447 Instance = this ;
48+ Options = Provider . GetRequiredService < IOptions < BootstrapBlazorOptions > > ( ) . Value ;
4549 }
4650
4751 /// <summary>
@@ -51,9 +55,11 @@ public TItem GetOrCreate<TItem>(object key, Func<ICacheEntry, TItem> factory) =>
5155 {
5256 var item = factory ( entry ) ;
5357
54- if ( entry . SlidingExpiration == null && entry . AbsoluteExpiration == null && entry . Priority != CacheItemPriority . NeverRemove )
58+ if ( entry . SlidingExpiration == null && entry . AbsoluteExpiration == null
59+ && entry . AbsoluteExpirationRelativeToNow == null
60+ && entry . Priority != CacheItemPriority . NeverRemove )
5561 {
56- entry . SetSlidingExpiration ( TimeSpan . FromMinutes ( 5 ) ) ;
62+ entry . SetSlidingExpiration ( Options . CacheManagerOptions . SlidingExpiration ) ;
5763 }
5864 return item ;
5965 } ) ! ;
@@ -65,9 +71,11 @@ public Task<TItem> GetOrCreateAsync<TItem>(object key, Func<ICacheEntry, Task<TI
6571 {
6672 var item = await factory ( entry ) ;
6773
68- if ( entry . SlidingExpiration == null && entry . AbsoluteExpiration == null && entry . Priority != CacheItemPriority . NeverRemove )
74+ if ( entry . SlidingExpiration == null && entry . AbsoluteExpiration == null
75+ && entry . AbsoluteExpirationRelativeToNow == null
76+ && entry . Priority != CacheItemPriority . NeverRemove )
6977 {
70- entry . SetSlidingExpiration ( TimeSpan . FromMinutes ( 5 ) ) ;
78+ entry . SetSlidingExpiration ( Options . CacheManagerOptions . SlidingExpiration ) ;
7179 }
7280 return item ;
7381 } ) ! ;
@@ -530,7 +538,7 @@ private static TResult GetValue<TModel, TResult>(TModel model, string fieldName)
530538 {
531539 if ( type . Assembly . IsDynamic )
532540 {
533- entry . SetAbsoluteExpiration ( TimeSpan . FromSeconds ( 10 ) ) ;
541+ entry . SetAbsoluteExpiration ( Options . CacheManagerOptions . AbsoluteExpiration ) ;
534542 }
535543
536544 return LambdaExtensions . GetPropertyValueLambda < TModel , TResult > ( model , fieldName ) . Compile ( ) ;
@@ -557,7 +565,7 @@ public static void SetPropertyValue<TModel, TValue>(TModel model, string fieldNa
557565 {
558566 if ( type . Assembly . IsDynamic )
559567 {
560- entry . SetAbsoluteExpiration ( TimeSpan . FromSeconds ( 10 ) ) ;
568+ entry . SetAbsoluteExpiration ( Options . CacheManagerOptions . AbsoluteExpiration ) ;
561569 }
562570 return LambdaExtensions . SetPropertyValueLambda < TModel , TValue > ( model , fieldName ) . Compile ( ) ;
563571 } ) ;
0 commit comments