Get startedGet started for free

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!

This exercise is part of the course

Introduction to NoSQL

View Course

Exercise 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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)
Edit and Run Code