Integrating Redis Cache and CDN on Azure
The course is part of these learning paths
This course provides an overview of Redis Cache and how to create a Redis Cache instance in Azure. With Redis Cache deployed in Azure, we’ll then connect an application to the cache.
Next, we’ll walk through the process of storing and retrieving data in Redis Cache. After covering Redis Cache, we’ll walk through an overview of what CDN is and what it’s used for. We’ll then develop some code for leveraging CDN. As we wrap up the course, we’ll cover the process for invalidating data in both Redis Cache and in a CDN.
This course is intended for IT professionals who are interested in earning Azure certification and those who need to incorporate Redis Cache or CDN into their solutions. To get the most from this course, you should have at least a moderate understanding of what caching is and why it’s used.
By the end of this course, you should have a good understanding of what Redis Cache and CDN are and what purposes they serve. You’ll also know how to connect to each from applications and how to purge or invalidate data in both.
- [Instructor] What we are going to do in this demonstration is connect to our Redis cache via Python through an interactive window in Microsoft Visual Studio. Once we connect to our cache, we are going to use the set command to store some data in the cache and then use the get command to pull that data out and display it. It's a basic demonstration, but it shows how to connect to the ready cache and how to store and retrieve data.
Before connection to our cache, we need to import the readis-py package. And what I am going to do is copy and paste some of these commands and explain them as we go.
So on the screen we have my Python interactive window open and what I am going to do is paste in this import command and essentially what this does is pull in that ready cache package, so we can use it to connect to our ready cache. We'll hit enter here, doesn't give us any feed back, but it doesn't give us an error either. So we know we are good.
And what we are going to do here is connect to our cache. So this is the connection string we are going to use to connect to our cache. We are storing this in a variable. You can see here that we have to specify the complete host name for our cache. And this is our host name that we give it when we deployed it earlier on. We need to specify the port we are going to connect over. And sixty-three eighty, by the way, is the default port number. The Db equals zero command here tells us that we are connecting to the zero data base. Remember, there are sixteen databases that comprise the data cache. So we are just specifying which database we are working with. The password here that we are specifying is actually the access key that we copy from our cache after we deployed it in Azure. And then lastly, we are just telling the command that we are going to use SSL to connect.
So with this command we hit enter and again there is no real feedback to tell us anything. What we are going to do now is perform a set command to store some data in the cache. So essentially performing this set against our variable. And we are put in some data in our cache and we can hit enter. So finally, we get some feedback true tell us that our storage set was successful. So now, what I am going to do here is to perform a get against our variable to pull the data back out. And on the screen here we can see that the get was successful.
What we will do on our next demonstration is create an actual Python script that goes out and communicates with our ready cache.
About the Author
Tom is a 25+ year veteran of the IT industry, having worked in environments as large as 40k seats and as small as 50 seats. Throughout the course of a long an interesting career, he has built an in-depth skillset that spans numerous IT disciplines. Tom has designed and architected small, large, and global IT solutions.
In addition to the Cloud Platform and Infrastructure MCSE certification, Tom also carries several other Microsoft certifications. His ability to see things from a strategic perspective allows Tom to architect solutions that closely align with business needs.
In his spare time, Tom enjoys camping, fishing, and playing poker.