Using IMemoryCache to cache data in-memory using .NET 5 [An Introduction]

preview_player
Показать описание
In this video, I am going to walk through how to cache data in-memory using the IMemoryCache interface in .NET 5.

Caching is a very useful mechanism to easily increase the performance of any application.

Previously I have covered topics on distributed cache services.

00:05 - Introduction of what is caching
02:45 - Explain the problem domain
03:34 - Create a new class for implementing cache using IMemoryCache
04:55 - Get an item from the cache using a key
05:50 - Add item to the cache
06:50 - Different overloads for adding cache
07:15 - Elaborate MemoryCacheEntryOptions object
07:35 - Explaining cache expiration and difference between sliding and absolute expiration policy
09:20 - Explanation of how to avoid stale data forever when using sliding expiration
10:15 - What is a post-eviction callback and how it can be useful
11:00 - Cache priority
11:15 - Size of the cache entry
11:50 - Mechanism I follow to add items to the cache using TryGetValue method
13:40 - Configuring dependency injection for IMemoryCache
14:05 - Explaining the overloads for AddMemoryCache extension method for adding IMemoryCache to the dependency injection
15:00 - explaining CompactionPercentage property
16:05 - Update the API to use the cache provider to get data
17:05 - Debug through the code and explain how the feature is working
Рекомендации по теме
Комментарии
Автор

I'm glad to have learnt something I didn't know existed. Thank you!

jmahachi
Автор

Thanks for that clear explanation, I was looking for something like this to implement.

nasserhossam
Автор

Excellent, pretty clear as most of your videos. Thanks for this hard work!

TonyAlcast
Автор

Was a very clean and clear explanation thank you for the video, keep up the good work 🤝

manjunaika
Автор

If we mark IUserCache to singleton, we wont be able to use the EF Core DB Context (which usually is transient) inside UserCache class. How do you suggest we overcome this?

PankajNikam
Автор

What is the difference between memory cache and response cache. Please explain....

vivekbarkam
Автор

does this work with Azure function. Or do we need to use Durable functions?

mathewjoseph
Автор

Lovely, your video is very helpful for me, I'm looking for a way how to cache data close to the application.
But my application is distributed application so I want to share data also then find out the way to send signals to each application for reloading cache.

dexterppp
Автор

Nicely done, but maybe the section at 16:20 could go a little slower. Thanks for the video.

snkite
Автор

You haven't mentioned that the NuGet package msut be installed first in order to use the IMemoryCache interface.

dnextreme