A Step-by-Step Guide for the Cache-Aside Pattern + Stampede Protection

  Рет қаралды 15,044

Milan Jovanović

Milan Jovanović

Күн бұрын

Пікірлер: 53
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@Ebrahem-outlook
@Ebrahem-outlook 6 ай бұрын
Thank you, Milon, you are a light on my way. I found you when I was searching for what is the Repository pattern. Now I can build powerful and scalable distributed systems, and I understand well almost everything about DDD, modular monolithic and microservices. I got to know many libraries thanks to you and learned from a lot... I am in the first year of the College of Computer and Electronics Engineering and I did not dream of learning about all this now... I hope we meet one day. Thank you for everything.
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
You are crushing it my man 💪 Keep up the good work!
@InshuMussu
@InshuMussu 5 ай бұрын
Whenever I watch your videos, I feel how poorly i write code. Thank you for all the unique and very, very practical, and useful videos.
@MilanJovanovicTech
@MilanJovanovicTech 5 ай бұрын
You're most welcome! :)
@shamjithharidasan
@shamjithharidasan 3 ай бұрын
Thank you Milan. Your tutorials are excellent
@MilanJovanovicTech
@MilanJovanovicTech 3 ай бұрын
Glad you think so!
@andersjuul8310
@andersjuul8310 6 ай бұрын
Thank you! As always -- great presentation, great coding style and well worth a watch even if there was little new knowledgewise. I look forward to the .Net 9 Caching video!
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Much appreciated!
@TellaTrix
@TellaTrix 6 ай бұрын
Thank you for sharing this on you channel. lot of new learning on you channel.
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
You are so welcome
@10Totti
@10Totti 6 ай бұрын
Great tutorial thanks!
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
You're welcome!
@jonny.rubber
@jonny.rubber 5 ай бұрын
Maybe it's worth to mention that the key is important in multi-user/tenant applications which have different security concerns per user. A "NormalUser" could have different rights as an "Administrator" for example, where a "NormalUser" would be restricted in the list of entities he/her could see. When using a multi-tenant environment, an "Organization"-part should also be added to the key (or maybe a completely separate Redis Instance). When the key doesn't take anything of that into consideration, users could get strange/forbidden results. I'm just starting to implement caching now, so am I right here, any tips?
@MilanJovanovicTech
@MilanJovanovicTech 5 ай бұрын
Yes, caching and authorization (who can do/see what) is tricky. The implementation you suggested is something I've done in the past in similar situations.
@GameSteals
@GameSteals 5 ай бұрын
What if the data being cached gets updated within the 2 mins window? Since we are not updating the cache on write wouldn't we get a stale value from the cache? While I understand that we shouldn't be caching all writes but can't we do this? When writing to DB, check if the value is present in the cache. If it is present, update the value in cache, otherwise do nothing.
@MilanJovanovicTech
@MilanJovanovicTech 5 ай бұрын
Invalidate the cache and update (write through). Or just invalidate the cache and let it be cached again on next request.
@GameSteals
@GameSteals 5 ай бұрын
@@MilanJovanovicTech Thank you! That makes sense.
@codewithkashif
@codewithkashif 3 ай бұрын
Excellent content and very well-written code! I have a quick question about the parameter named 'factory'. What was the reasoning behind choosing this name, and are there any other potential alternatives?
@MilanJovanovicTech
@MilanJovanovicTech 3 ай бұрын
It's a factory that creates the resource if it's not in the cache, is all
@InshuMussu
@InshuMussu 5 ай бұрын
Hi, can I ask something, why don't use in memory cache with redis, we should check in memory first if not found then goto redis, in that way we can save network call. I don't know, may be I am missing something because I have never seen this approach. Could you please advise?
@MilanJovanovicTech
@MilanJovanovicTech 5 ай бұрын
HybridCache will take care of this
@InshuMussu
@InshuMussu 5 ай бұрын
@MilanJovanovicTech yes thank you, since HyridCache is introduced in .net 9, before .net 9 it should be using by manually combining both inmemory and redis for the low latency, this approch seems very powerful to me but it's not commonly discussed in internet don't know if there is drawback..
@compman73
@compman73 6 ай бұрын
It was awesome Thanks for sharing 👍
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Glad you liked it
@ChristopherBriddock
@ChristopherBriddock 6 ай бұрын
Hey Milan, can you do a video about EF Core and Temporal tables?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
At some point, yeah
@phw1009
@phw1009 6 ай бұрын
Which project should I put `CacheAside` class in Clean-Architecture?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Where do we place external concerns?
@phw1009
@phw1009 6 ай бұрын
@@MilanJovanovicTech Oh, I guess Infrastructure...? Then, should I put it inside Persistence project?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
@@phw1009 I would usually place it inside Infrastructure
@neranjansugumar683
@neranjansugumar683 6 ай бұрын
hey Milan, can you please let us know the theme you're using?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
It's ReSharper
@vamvdotnet
@vamvdotnet 6 ай бұрын
Hello Milan! Excellent video! Very useful information! Congrats! By the way, do you happen to have a video that deep dives into Distributed Locking (what it is, real-world scenarios, how to implement in Redis or another cache technology)? It would be really great! See ya!
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Sadly, I don't have anything touching distributed locking (so far). But I've been meaning to make some content around that 😅 While you wait, you can checkout Redlock: github.com/samcook/RedLock.net
@vamvdotnet
@vamvdotnet 6 ай бұрын
@@MilanJovanovicTech No problem, my lad :) You just did help a whole bunch by giving me this pointer! Thank you once again :)
@DesaiBharat702
@DesaiBharat702 6 ай бұрын
How to use factory pattern for large property?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
What do you mean by larger property?
@DesaiBharat702
@DesaiBharat702 6 ай бұрын
If a class have more than property around 20 so in entity we mark property as private and create a factory method it difficult to set all twenty property using factory
@Locustfiretree
@Locustfiretree 6 ай бұрын
@@DesaiBharat702 Builder pattern is one option, or you could consider the class is doing too much if there are too many properties.
@andersjuul8310
@andersjuul8310 6 ай бұрын
Would you cache the dto or the entity?
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Preferably DTO
@malcolmlaraposada5300
@malcolmlaraposada5300 6 ай бұрын
nice content
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Thanks!
@comroec
@comroec 6 ай бұрын
I need a sample Blazer project with a report generate. pls
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Won't find it in this video
@andersjuul8310
@andersjuul8310 6 ай бұрын
😂​@@MilanJovanovicTech
@JoaoSilva-rz4js
@JoaoSilva-rz4js 6 ай бұрын
You missed a return if your data was fetched from cache
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Where?
@JoaoSilva-rz4js
@JoaoSilva-rz4js 6 ай бұрын
When first applying the cache on the minimal API. It works on the example because you press continue. Yourre just calling results.ok not actually returning
@JoaoSilva-rz4js
@JoaoSilva-rz4js 6 ай бұрын
Minute 7:57
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
@@JoaoSilva-rz4js Oh lol, you're right. Typo.
Completely Get Rid of Exceptions Using This Technique
19:24
Milan Jovanović
Рет қаралды 27 М.
The Right Way To Build Async APIs in ASP.NET Core
20:12
Milan Jovanović
Рет қаралды 24 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
The New .NET 9 HybridCache That You Must Upgrade To!
14:34
Nick Chapsas
Рет қаралды 56 М.
Event-Driven Architecture (EDA) vs Request/Response (RR)
12:00
Confluent
Рет қаралды 179 М.
Exceptions Are Extremely Expensive… Do This Instead
17:15
Milan Jovanović
Рет қаралды 50 М.
Creating a State Machine Saga With MassTransit (Orchestrated Saga)
15:41
Milan Jovanović
Рет қаралды 16 М.
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 117 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 376 М.
Your REST API Errors Are Wrong. Problem Details Will Fix This
16:14
Milan Jovanović
Рет қаралды 12 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 321 М.
Caching Pitfalls Every Developer Should Know
6:41
ByteByteGo
Рет қаралды 130 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН