CommencerCommencer gratuitement

Storing key-value data with Redis

Redis is a powerful tool used to store key-value pairs and is especially common in web applications. In this example, you're a developer creating a widget that shows the current weather for users of an application and leveraging Redis to cache this information.

To help get you stared, a connection to the Redis cluster has been created and is available in the variable redis_conn. Go get 'em!

Cet exercice fait partie du cours

Introduction to NoSQL

Afficher le cours

Instructions

  • Store the value "London" at the key "city".
  • Using the key "sunshine", store the value 7
  • Retrieve the values stored at the "city" and "sunshine" keys, take a look at the printed results.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Store the city key-value pair
redis_conn.____("____", "London")

# Store the sunshine key-value pair
____.____("____", "____")

# Retrieve values stored at the city and sunshine keys
city = redis_conn.____("____")
sunshine = ____.____("____")

print(city)
print(sunshine)
Modifier et exécuter le code