Select Page

This is a small code snippet demonstrating interacting with an Azure PAAS Redis Cache

import redis
import sys

redis_fqdn = ""
redis_key = ""

r = redis.StrictRedis(host=redis_fqdn, port=6380, password=redis_key, ssl=True)

# Test latency to redis
result =
print(f"Ping response {str(result)}")

# Create an object in redis

# Create an object in redis with an expiration of 30seconds

# Get an object value from redis
val = r.get("OBJECT_KEY")

# Get an objects time to live (TTL)
ttl = r.ttl("OBJECT_KEY")