Implementing In-Memory Caching in ASP.NET Core Applications
Вставка
- Опубліковано 22 кві 2024
- ►► Master Web API development Best Practices: bit.ly/3TnqoFQ
►► Build great web apps in Blazor WebAssembly: bit.ly/437g87T
►► Support us on Patreon and get the source code: / codemaze
In this video, I will talk about the caching basics and how to implement In-Memory Caching to improve performance and response speed in ASP.NET Core Web API applications.
What is Caching?
Caching is the technique of storing frequently accessed data at a temporary location for quicker access in the future. This can significantly improve the performance of an application by reducing the time required for connecting with the data source and sending data across the network.
In-memory caching is the simplest form of cache in which the application stores data in the memory of the web server. This is based on the IMemoryCache interface which represents a cache object stored in the application’s memory.
FOLLOW US ON SOCIAL MEDIA!
►► / marinko-spasojevic
►► / codemazeblog
►► / codemazeblog
Thank you all for watching and for your support.
►► If you want to master Web API development using best practices, check out our Web API book: bit.ly/3x75ZMM
►► Also, to build great full-stack apps with Blazor, check out our course: bit.ly/3Pw3Y33
Thanks a lot @CodeMaze for talking about Cache Stampede using SemaphoreSlim in In-Memory Caching. I was looking for that topic
Glad it was helpful! Thank you for watching the video.
Good one !!!
Thank you! Cheers!
Thank you for this video, crazy that it was just created yesterday😂. Right timing for me I guess
You are most welcome. Thank you too for watching the video. As many would say, there is no wrong time for good stuff :)
Thanks @CodeMaze for the video.
Are you going to talk about cache stampede?
Thank you too for watching. I will see about that topic. It is interesting for sure, just can be a bit more theoretical as well. Thank you for the suggestion though.
Great
Thanks.
I'd like to create a service for caching. should I return ValueTask instead of Task from the methods?
ValueTask SetAsync(string key, T value, CancellationToken token = default)
Using ValueTaks with caching operations should be recommended but also tested with benchmarks. It doeasn't have to be a faster operation, because that's not the main purpose for ValueTask, but it can definitely reduce memory allocations. We have a great article on that topic: code-maze.com/csharp-task-and-valuetask/, you can find a bit more info there.
@@CodeMaze I already read it 👍
You are the best person
Thanks 🤍
Thank you too for watching. Cheers.