Overview
Azure Cache for Redis is a fully managed, in-memory data store service built on the open-source Redis (Remote Dictionary Server) project. It provides a high-performance, scalable, and secure cache that improves the speed and responsiveness of applications by storing frequently accessed data in memory. This reduces the need to query slower backend databases, thereby lowering latency and improving throughput for read-heavy workloads. The service is suitable for a range of application architectures, from web and mobile applications to microservices and real-time analytics systems.
Developers can use Azure Cache for Redis for various purposes, including caching database query results, application session state management, and full page caching. Its publish/subscribe capabilities also enable its use as a message broker for real-time data streams and event-driven architectures. The service supports all standard Redis data structures, such as strings, hashes, lists, sets, and sorted sets, allowing for versatile data modeling. Additionally, it offers features like data persistence and geo-replication (in Premium and Enterprise tiers) to ensure data durability and high availability across regions.
The service integrates with other Azure offerings, including Azure Web Apps, Azure Functions, and Azure Kubernetes Service (AKS), simplifying setup and deployment within the Azure ecosystem. For developers already familiar with Redis, the transition is streamlined because Azure Cache for Redis uses standard Redis commands and client libraries. Microsoft offers different tiers—Basic, Standard, Premium, Enterprise, and Enterprise Flash—to accommodate varying performance, availability, and feature requirements, from development/test environments to production workloads requiring high scale and advanced capabilities like active geo-replication and Redis modules.
Key features
- Managed Service: Microsoft manages the infrastructure, patching, and scaling, reducing operational overhead for users (learn.microsoft.com).
- High Performance: In-memory data storage delivers sub-millisecond latency for data retrieval.
- Data Structures: Supports native Redis data structures including strings, hashes, lists, sets, sorted sets, and more (redis.io).
- Scalability: Tiers offer options for scaling cache size and throughput, with clustering available in Premium and Enterprise tiers.
- Security: Includes features like VNet integration, private link, and data encryption at rest and in transit.
- Persistence: Premium and Enterprise tiers offer data persistence to Azure Storage, protecting against data loss during restarts.
- Geo-replication: Active geo-replication (Enterprise tiers) and passive geo-replication (Premium tier) enable high availability and disaster recovery across Azure regions (azure.microsoft.com).
- Redis Modules: Enterprise tiers support Redis Enterprise modules such as RediSearch, RedisJSON, RedisGraph, and RedisTimeSeries.
- Monitoring and Diagnostics: Integrates with Azure Monitor for performance metrics, logs, and alerts.
Pricing
Azure Cache for Redis pricing is based on the selected tier (Basic, Standard, Premium, Enterprise, Enterprise Flash), cache size, and Azure region. Costs are calculated hourly. The Basic tier is suitable for development and testing, while Standard offers higher availability with a two-node primary/replica setup. Premium, Enterprise, and Enterprise Flash tiers provide advanced features like clustering, VNet integration, data persistence, and geo-replication.
Below is a summary of starting hourly pricing for select tiers as of May 7, 2026. For detailed and up-to-date pricing, refer to the official Azure Cache for Redis pricing page.
| Tier | Cache Size | Approx. Price Per Hour | Key Features |
|---|---|---|---|
| Basic C0 | 250 MB | $0.02 | Single node, suitable for dev/test |
| Standard C0 | 250 MB | $0.034 | Two nodes (primary/replica), 99.9% SLA |
| Premium P1 | 6 GB | $0.27 | Clustering, VNet, Persistence, Passive Geo-replication |
| Enterprise E1 | 12 GB | $0.60 | Active Geo-replication, Redis Enterprise modules |
For complete and current pricing details, visit the Azure Cache for Redis pricing page.
Common integrations
- Azure Web Apps: Integrate for session state management and data caching to improve web application performance. (learn.microsoft.com)
- Azure Functions: Use as a high-speed data store or message broker for serverless applications.
- Azure Kubernetes Service (AKS): Deploy applications on AKS and use Azure Cache for Redis for distributed caching.
- ASP.NET Core: Utilize Redis as a distributed cache provider or for session storage in ASP.NET Core applications. (learn.microsoft.com)
- Other Azure Databases (e.g., Azure SQL Database, Azure Cosmos DB): Cache frequently accessed data to reduce load and improve response times for backend databases.
- Third-party client libraries: Compatible with various Redis client libraries for languages like Python (e.g.,
redis-py), Node.js (e.g.,ioredis), and Java (e.g., Jedis).
Alternatives
- Amazon ElastiCache for Redis: A managed Redis service offered by AWS, providing similar caching and in-memory data store capabilities.
- Google Cloud Memorystore for Redis: Google Cloud's fully managed service for Redis, suitable for high-performance applications.
- Redis Enterprise Cloud: A fully managed Redis offering directly from Redis Labs, providing advanced features and deployment options.
- DigitalOcean Managed Redis: A managed Redis database service for developers, focusing on simplicity and ease of use.
- Amazon ElastiCache for Memcached: An alternative caching solution on AWS, based on the Memcached protocol, often used for simpler key-value caching.
Getting started
To get started with Azure Cache for Redis, you first provision an instance through the Azure portal or CLI. Once provisioned, you can connect to it using standard Redis client libraries in your preferred programming language. The following Python example demonstrates connecting to and performing basic operations on an Azure Cache for Redis instance using the redis-py library.
import redis
import os
# Retrieve connection string from environment variables for security
# The connection string will look something like:
# "yourcache.redis.cache.windows.net:6380,password=YOUR_PASSWORD,ssl=True,abortConnect=False"
REDIS_CONNECTION_STRING = os.environ.get("REDIS_CONNECTION_STRING")
if not REDIS_CONNECTION_STRING:
raise ValueError("REDIS_CONNECTION_STRING environment variable not set.")
# Parse the connection string to extract host, port, and password
# A more robust parsing mechanism might be needed for complex strings
def parse_redis_connection_string(conn_string):
parts = conn_string.split(',')
host_port = parts[0].split(':')
host = host_port[0]
port = int(host_port[1])
password = None
ssl = False
for part in parts[1:]:
if part.startswith('password='):
password = part.split('=')[1]
elif part.startswith('ssl=') and part.split('=')[1].lower() == 'true':
ssl = True
return host, port, password, ssl
host, port, password, ssl = parse_redis_connection_string(REDIS_CONNECTION_STRING)
try:
# Connect to Azure Cache for Redis
# decode_responses=True decodes responses from bytes to strings directly
r = redis.Redis(host=host, port=port, password=password, ssl=ssl, decode_responses=True)
print("Successfully connected to Azure Cache for Redis.")
# Set a key-value pair
key = "mykey"
value = "Hello, Azure Redis!"
r.set(key, value)
print(f"Set '{key}': '{value}'")
# Get the value back
retrieved_value = r.get(key)
print(f"Retrieved '{key}': '{retrieved_value}'")
# Using a hash
hash_key = "user:100"
user_data = {"name": "Alice", "email": "[email protected]"}
r.hmset(hash_key, user_data)
print(f"Set hash '{hash_key}': {user_data}")
retrieved_user_data = r.hgetall(hash_key)
print(f"Retrieved hash '{hash_key}': {retrieved_user_data}")
# Increment a counter
counter_key = "view_count"
r.incr(counter_key)
r.incr(counter_key)
current_count = r.get(counter_key)
print(f"Current view count for '{counter_key}': {current_count}")
# Delete keys
r.delete(key, hash_key, counter_key)
print(f"Deleted keys: {key}, {hash_key}, {counter_key}")
except redis.exceptions.ConnectionError as e:
print(f"Could not connect to Redis: {e}")
except Exception as e:
print(f"An error occurred: {e}")
Before running this code, ensure you have the redis Python library installed (pip install redis) and replace REDIS_CONNECTION_STRING with your actual connection string from your Azure Cache for Redis instance, preferably by setting it as an environment variable.