Skip to content

Files

Latest commit

 

History

History
60 lines (48 loc) · 1.93 KB

cache-python-get-started.md

File metadata and controls

60 lines (48 loc) · 1.93 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.devlang ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author
How to use Azure Redis Cache with Python | Microsoft Docs
Get started with Azure Redis Cache using Python
redis-cache
steved0x
douge
v-lincan
f186202c-fdad-4398-af8c-aee91ec96ba3
cache
python
hero-article
cache-redis
tbd
01/06/2017
sdanie

How to use Azure Redis Cache with Python

[!div class="op_single_selector"]

This topic shows you how to get started with Azure Redis Cache using Python.

Prerequisites

Install redis-py.

Create a Redis cache on Azure

[!INCLUDE redis-cache-create]

Retrieve the host name and access keys

[!INCLUDE redis-cache-create]

Enable the non-SSL endpoint

Some Redis clients don't support SSL, and by default the non-SSL port is disabled for new Azure Redis Cache instances. At the time of this writing, the redis-py client doesn't support SSL.

[!INCLUDE redis-cache-create]

Add something to the cache and retrieve it

>>> import redis
>>> r = redis.StrictRedis(host='<name>.redis.cache.windows.net',
      port=6380, db=0, password='<key>', ssl=True)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
b'bar'

Replace <name> with your cache name and key with your access key.