DEV Community

Renicius Pagotto
Renicius Pagotto

Posted on

Azure Cache for Redis - Overview

Hi everyone, today we are going to talk about Azure Cache for Redis, a powerful resource offered by Azure for caching strategies.

What is Azure Cache for Redis?

Azure Cache for Redis provides an in-memory data store based on Redis Software. It can also help improve the performance and scalability of applications that make heavy use of any type of data source to get data.

Azure Cache for Redis is a low-latency, high-throughput data storage solution that is ideal for modern applications and can be used as distributed data, content caching, and session storage.

Why cache data?

The main purpose of a cache is to increase data retrieval performance by reducing the need to access the data source directly.

Scenarios to use

Azure Cache for Redis can be used in some scenarios to improve software performance, as explained below

Data Store

Azure Cache for Redis is an excellent choice when the application consumes heavily the database to get data. In that case, we can use Azure Cache to cache the data to avoid this large number of operations.

Content cache

Many web pages are generated from templates that use static content such as headers, footers, and banners. These static items should not change often. Using an in-memory cache provides fast access to static content compared to back-end data stores. This pattern reduces processing time and server load, allowing web servers to be more responsive.

Session Store

This pattern is commonly used with shopping carts and other user history data that a web application might associate with user cookies. Storing too much in a cookie can have a negative effect on performance as the cookie size grows and is passed and validated with each request. A typical solution uses the cookie as a key to query the data in a database. Using an in-memory cache, such as Azure Cache for Redis, to associate information with a user is much faster than interacting with a full relational database.

Integration cache

Many applications need to consume third-party APIs to get data to use in a business process or just to return to the user. As this scenario involves an HTTP request, we may suffer from network issues, unavailability of APIs that will directly affect our application, therefore caching the data of an integration is necessary and helps to increase availability as well.


At certain times, we need to leverage the use of caching, eliminating old data that is not in use or even defining a time in which the data will remain in cache before being automatically removed.

Azure Cache for Redis, like Redis, has some policies that will help to maximize the use of the cache.

Key Expiration

An expiration value is a value that is defined when the object is cached. This value represents how long the data will be available in cache before it is automatically removed.

Memory Policies

Maxmemory policy configures the eviction policy for the cache and allows you to choose from the following eviction policies:

  • volatile-lru: The default eviction policy, removes the least recently used key out of all the keys with an expiration set.

  • allkeys-lru: Removes the least recently used key.

  • volatile-random: Removes a random key that has an expiration set.

  • allkeys-random: Removes a random key.

  • volatile-ttl: Removes the key with the shortest time to live based on the expiration set for it.

  • noeviction: No eviction policy. Returns an error message if you attempt to insert data.

  • volatile-lfu: Evicts the least frequently used keys out of all keys with an expire field set.

  • allkeys-lfu: Evicts the least frequently used keys out of all keys.

Below is an example image of how we can define this using the Azure Portal.

Image description

How to configure Azure Cache for Redis

Open the Azure Portal and in the search engine type Azure Cache for Redis and select the resource

Image description

Select +Create option

Image description

Now, let's start creating the resource, for that, we need to provide some information as shown in the image below.

Image description

Moving on to the Networking tab, here we define whether the resource will be available through a private endpoint, public endpoint or virtual network.

Image description

Moving to the Advanced tab, here we can define whether the resource can be accessed without TLS. We can choose the Redis version as well.

Image description

Finally, go to the Review + create tab and select Create at the bottom of the page to create the resource.

Image description

This operation may take a few minutes and after that your resource will be available to be used in the application.

Image description

If you want to change the settings after the resource is created, select the Advanced settings option to display all the settings.

Image description

To use Azure Cache for Redis in your application, you will need to obtain the connection string and the access key, for that select the Access Keys option to obtain this information.

Image description

Did you like this post? Want to talk a little more about? Leave a comment with your questions and ideas or get in touch through LinkedIn.

Top comments (0)