Using Redis as a cache on Azure
In this recipe, we will learn how to use Redis on Azure as a cache in-memory system with ASP.NET Core MVC applications.
Getting ready
First, we will connect to our Azure subscription, create a Redis cache provider, launch VS 2017, and create an empty web application.
How to do it...
- First, let's launch http://portal.azure.com, connect with our subscription, and select
Redis Caches
:
- Then we will create a Redis cache. To do that, we configure it, adding a
DNS name
, aSubscription
, aResource group
, aLocation
, and aPricing tier
:
- Refreshing the
Redis Caches
section, we can see the new Redis cache just created:
- Now Redis is created on Azure, we launch VS 2017 and create an empty web application.
- First, we have to import the
StackExchange.Redis
dependency in the project to manipulate the Redis API:
"StackExchange.Redis": "1.2.6"
- Next, we create some extension methods to use Redis more efficiently, because we have to serialize and deserialize the
clr
object to store...