Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type languages name description products
sample
python
Quickstart: Use Azure Cache for Redis in Python
Learn how to incorporate Azure Cache for Redis into a Python app.
azure
azure-cache-redis

Quickstart: Use Azure Cache for Redis in Python

This sample show you how to incorporate Azure Cache for Redis into a Python app. See the accompanying article on the documentation site for details, including best practices and how to create the sample code from scratch.

Prerequisites

Install redis-py

Redis-py is a Python interface to Azure Cache for Redis. Use the Python packages tool, pip, to install the redis-py package from a command prompt.

The following example used pip3 for Python 3 to install redis-py on Windows 11 from an Administrator command prompt.

Install the redis-py Python interface to Azure Cache for Redis

Run the sample

Download the sample code to your development PC.

Change directories to the folder containing this sample.

Edit the PythonApplication1.py source. Replace <Your Host Name> and <Your Access Key> with the values from your Azure Cache for Redis instance. Your host name is of the form <DNS name>.redis.cache.windows.net.

Run PythonApplication1.py with Python.

Important

For Azure Cache for Redis version 3.0 or higher, TLS/SSL certificate check is enforced. ssl_ca_certs must be explicitly set when connecting to Azure Cache for Redis. For RedHat Linux, ssl_ca_certs are in the /etc/pki/tls/certs/ca-bundle.crt certificate module.

References