To understand how to set up your Azure Redis Cache Database and more about its usage, check it here.

In this approach, we are going to use StackExchange.Redis to connect with the Azure Redis Database and BinaryFormatter to serialize and deserialize the data. No NuGet packages are required since Azure Redis Cache Database is already there inside .NET Core package.

How to do it?

Follow the next steps.

Complex Object Sample

This is the complex object used in this sample.

[Serializable]

publicclass SampleObject

{

publicint Id { get; set; }

publicstring Name { get; set; }

publicstring Country { get; set; }

}

PS.: As we must serialize the data in order to send or receive from Azure Redis Cache, this [Serializable] tag is a must.