Distributed Caching In ASP.NET Core With Redis | Introduction

preview_player
Показать описание

In this video, I'm going to show you how you can add caching to your ASP.NET Core Web API using Redis. We're going to run Redis inside of a Docker container and connect to this Redis instance from our ASP.NET Core application. We'll use the IDistributedCache interface to communicate with Redis, which makes our ASP.NET Core implementation easier.

Join my weekly .NET newsletter:

Read my Blog here:

Subscribe for more:

Chapters
0:00 Replace IMemoryCache with IDistributedCache
3:41 Implementing caching with IDistributedCache
9:13 Testing the implementation
12:23 Adding a custom ContractResolver for private members
14:38 Testing the improved implementation
15:38 What is the performance with Redis?
16:33 Make caching work with EF change tracking
Рекомендации по теме
Комментарии
Автор

Once again you provide a concise yet comprehensive explanation of everything you're doing. You are producing an excellent series of videos.

EmptyGlass
Автор

Jako dobar i edukativan sadrzaj. Samo tako nastavi

DermoniS
Автор

Be careful! while updating the cached value. Attaching to the DbContext is not enough. You must invalidate the cached value while saving (Unit of work). Otherwise all subsequent Get request will get the old Member value from the cache and not the updated one.

MarcusKaseder
Автор

It was a very practical and complete training, thank you

vahidghamari-ugbn
Автор

Amazing content Milan. Thank you for your time so much

MXDMND_
Автор

I can say for sure it is a a comprehensive explanation. thanks for everything you are doing. Can you start a playlist for unit testing, integration testing

fdyreog
Автор

Nice introduction! Next... handling cache invalidation/expiry!

ryanc
Автор

JsonSerializerSettings can be additionally stored as a private static field in order to not create a new instance with each request

krzysztofzon
Автор

Hi Milan, Awesome videos and explanation❤
Can you pls make video on the architecture, design and basic implementation on integration of different CRMs(Zoho/Dynamics, Salesforce, Pipedrive etc) into an web application keeping DDD in mind. How do you maintain consistency in DB, exponential backoff, retry mechanism, rate limiters etc....With EF and DB design.
Or you can take example of different mailing services too like Gmail, Zoho mail, SMTP.
It will be very usefull if you make a video from the System design HLD and LLD perspective.

modernsanskari
Автор

Hey Milan Nice Explanation about redis and Distrubuted Cache, i was wondering how cache should/will work in case of filterting and pagination can you please make an video about this

justpeakyblindersthings
Автор

Interesting about the change tracker for caching, it makes sense. But I havent thought about it so I will need to have another check. In my cached repository it updates as expected without using the attach call.

PelFox
Автор

This was great! How did you get your data tips to auto show when debugging?? That's so nice to not have to hover for every value. Is that an extension??

pinpaho
Автор

Hi Milan,
Thank u for the post.
I have question.
Should we handle caching in a Middleware?
For example if we have something in cache then we return from a call right away.
If we don't have anything in cache then we hit an entry point and on our "way back" if response is OK (200) we will write to cache.
Thus we will not mix the busness logic with caching - something like a "decarator" pattern.

alexlo
Автор

Nice stuff thanks for explaining this in a neat format . What is the best pattern you recommend for creating a search engine api ?

balajisairamnarasimhan
Автор

Thank you Milan..
Query : How to define expiry time or invalidate the cache.. could you please make separate video on to cover this.

rishithakur
Автор

I used the interface of distributed cache in a real project but i faced a lot of connection issues when we moved the project to azure cloud and bought azure redis cache so i had to switch back to stackexchange redis nuget to handle the connections better

I hope if you can explain this issue and if there is a reason for it

mahmoudalaskalany
Автор

Hi Milan, Nice video once again. ❤
What if the application has more than 200 permissions, should I go for jwt or other process?

salmanshafiq
Автор

hey milan i have a question if ef core caches data by default then using IMemoryCache with ef core is useless right ? i mean if ef core is already doing the job why should we use IMemoryCache?

hannahbaker
Автор

Thanks for great tut!
Is there any way to flush DB but stopping docker?
Sometimes I want to make tests, and the thing is that redis db still contains X key, but I need to re-build it, is it possible?

rodolfoa.calvojaubert
Автор

Hello Milan!

Isn't it recommended to secure the Redis service? In this way it can be accessed by anybody, right? Can you give me some advice on how to secure it?

vcsoul