We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fea2585 commit 06e0a47Copy full SHA for 06e0a47
src/LinkDotNet.Blog.Web/Features/Components/ShortBlogPost.razor
@@ -66,10 +66,10 @@
66
protected override void OnInitialized()
67
{
68
var key = "reading-time-" + BlogPost.Id;
69
- if (!MemoryCache.TryGetValue(key, out readingTime))
+ readingTime = MemoryCache.GetOrCreate(key, entry =>
70
71
- readingTime = ReadingTimeCalculator.CalculateReadingTime(BlogPost.Content);
72
- MemoryCache.Set(key, readingTime, TimeSpan.FromHours(1));
73
- }
+ entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1);
+ return ReadingTimeCalculator.CalculateReadingTime(BlogPost.Content);
+ });
74
}
75
0 commit comments