Тёмный

Using Redis cache with ASP.Net Core Web API (Both running inside Docker containers) 

DotNet Core Central
Подписаться 27 тыс.
Просмотров 25 тыс.
50% 1

In this video, I will demonstrate how to use Redis as a distributed in-memory caching engine with ASP.Net Core and C# application.
#csharp #redis #aspdotnetcore
I am going to cover the following high-level topics:
1. What is Redis Cache
2. Key features provided by Redis Cache
3. Installing Redis Cache in a Docker container
4. Using Caching Redis in .Net Core Web API
For more detail, please visit my blog: dotnetcorecentral.com/blog/re...
Using a caching solution becomes important when we are building a high performant web-based application or micro-services system. And Redis is one of the most popular in-memory distributed caching solutions available out there.
Redis is an open-source distributed in-memory data store. We can use it as a distributed (no-SQL) database or as a distributed in-memory cache or a pub/sub messaging engine, and more recently streaming engine. The most popular use case I have encountered so far, is using it as a distributed in-memory caching engine. Hence in this video, I will implement using the caching feature of Redis in .Net Core application.
Redis supports multiple data structures. But the most frequently used one is a string. Though there are use cases for other data structures like Hashes and Sets.
Redis also supports a stream implementation starting from version 5.
For the ASP.Net Core Web API application, I have used StackExchange.Redis nuget package, which is an implementation of Redis client. This nuget package supports all the core features provided by Redis.
Redis also comes with redis-cli which is a command-line interface for Redis. And it supports all the commands of Redis. It is a very handy tool when debugging issues or even verifying/testing during the initial development process.
In conclusion, using Redis is very simple and straightforward. The redis-cli is very easy to use. The StackExchange.Redis nuget package is also very simple. As far as an in-memory distributed cache is concerned, its a very good tool. I am not user I will ever use it anything beyond just a caching platform. I am not sold into using it as a Pub/Sub engine or even a stream. But this is just my personal preference, since I use other product for these features.

Наука

Опубликовано:

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 34   
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
In 3:20 I said "export the port" by mistake, what I meant is "I am going to expose the Redis port 6379 to the local machine so that we can access the Redis running inside the container from the applications running outside of the container".
@salnkv
@salnkv 4 года назад
Thanks! Very clear and helpful!
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
Salnkv I’m glad, thanks for watching the video.
@SanjeevKumar-mk6yt
@SanjeevKumar-mk6yt 4 года назад
Cleaned and detailed explanation, good job
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
@Sanjeev Kumar thank you!
@nitinzodape1123
@nitinzodape1123 4 года назад
very useful.... Thanks buddy :)
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
Glad you liked the video, thanks for watching.
@tareqyousef1516
@tareqyousef1516 4 года назад
Thank you that was clear and simple. have few points 1- is it possible to demo StringGetAsync method 2- add value as json object serialize,deserialize 3- publish to github 4-get list of values by key pattern
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
Tareq Yousef can you please elaborate point 4.
@tareqyousef1516
@tareqyousef1516 4 года назад
​@@DotNetCoreCentral simply wan to get list of all keys as json array starts with username* usernameAdmin usernameReader usernameAuditor
@damiandanev9271
@damiandanev9271 4 года назад
You know what would be amazing? Using Redis TimeSeries with ASP.Net! Also Redis can be used as a standart message bus for SignalR, if I am not mistaken.
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
Yes, it could be used for the message bus, but I am not sure I would use Redis for that. Maybe I will play around with it to understand the pros and cons.
@damiandanev9271
@damiandanev9271 4 года назад
@@DotNetCoreCentral Why not? If I am not mistaken that's the default message bus for SignalR when you scale it out. The Azure SignalR managed service uses redis too I think.
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
@@damiandanev9271 SignalR uses it for backplane if I am not mistaken. In which case it makes sense. So for a message bus, maybe. I was thinking more in terms of pub/sub when you said message bus, my bad. For a pub/sub I would go with something like RabbitMQ.
@vivekgowda1576
@vivekgowda1576 4 года назад
Before enter the (cmd) docker pull redis should we install the docker in our local system.Please suggest i'm new to this
@DotNetCoreCentral
@DotNetCoreCentral 3 года назад
Sorry for the late response. Yes Docker desktop should be installed in your PC.
@aj.arunkumar
@aj.arunkumar Год назад
awesome video
@DotNetCoreCentral
@DotNetCoreCentral Год назад
Thanks!
@MARCAJAL
@MARCAJAL 3 года назад
Thanks you!
@DotNetCoreCentral
@DotNetCoreCentral 3 года назад
@Marcelo Ajalla, thanks for watching!
@shreyasjejurkar1233
@shreyasjejurkar1233 4 года назад
Nice!
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
Shreyas Jejurkar thanks!
@ningguo1947
@ningguo1947 4 года назад
There's no DockerNAT under ipconfig anymore. What's the alternative one?
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
I am not sure which use case you will use that, as I have not used DockerNAT before. If you can elaborate it more maybe I can answer this. FYI: In production, all my containers run in Linux. I have not used any windows container in the production setting yet.
@ningguo1947
@ningguo1947 4 года назад
@@DotNetCoreCentral At 15:22
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
@@ningguo1947 Got it, I will take a look.
@ayushgupta9892
@ayushgupta9892 4 года назад
Why have you not used IDistributedCache interface ?
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
@Ayush Gupta here is no particular reason. I was using the API provided straight from StackExchange.Redis NuGet package. Whereas IDistributedCache is wrapped by Microsoft.Extensions.Caching.Distributed. Which under the hood uses StackExchange.Redis interfaces for interacting with Redis. Maybe I will create a video with IDistributedCache and compare and contrast. Thanks for the suggestion.
@ayushgupta9892
@ayushgupta9892 4 года назад
@@DotNetCoreCentral Great ! I look forward to it. Can you also create video on distributed lock in dotnet core using Redis ?
@ashishgour6665
@ashishgour6665 4 года назад
Hiii anyone have sample code?
@DotNetCoreCentral
@DotNetCoreCentral 4 года назад
@Ashish Gour, the code is available here: github.com/choudhurynirjhar/redis-demo
@I3righter0101
@I3righter0101 3 года назад
█╗░░░░░░█████╗░░░░░░░███████╗████║░░░░░██╔══██╗░░░░░░██╔════╝████║░░░░░██║░░██║█████╗█████╗░░████║░░░░░██║░f░██║╚════╝██╔══╝░░█████████╗╚█████╔╝░░░░░░██║░░░░░██╚══════╝░╚════╝░░░░░░░╚═╝░░░░░╚═!
@DotNetCoreCentral
@DotNetCoreCentral 3 года назад
@vkl chan, I am not sure if RU-vid is not able to translate the character you used or it's just artwork. If it is artwork, then I am not sure this is the right forum. And if it is lost in translation, can you please edit the comment in English? Thanks!
Далее
Memcached as Distributed Cache in .Net Core Application
24:39
.NET 6 - Web API Caching with Redis ⏲🌐
1:04:23
Просмотров 34 тыс.
.NET Docker Tutorial - SQL Server Docker [.NET Docker]
20:19
Top 5 Redis Use Cases
6:28
Просмотров 171 тыс.
Deploy a .NET Core API with Docker (Step-by-Step)
36:17
I've been using Redis wrong this whole time...
20:53
Просмотров 340 тыс.
Здесь упор в процессор
18:02
Просмотров 375 тыс.
Красиво, но телефон жаль
0:32
Просмотров 1,3 млн