Question: Is Redis NoSQL?


Redis is a key-value store, which means that it stores data as key-value pairs. It is designed to be very fast and to handle large amounts of data. Redis supports a wide range of data structures, including strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, and geospatial indexes.

Here's an example of storing and retrieving data in Redis using the Python Redis client:

import redis # Connect to Redis r = redis.Redis(host='localhost', port=6379, db=0) # Set a key-value pair r.set('mykey', 'myvalue') # Get the value of a key value = r.get('mykey') print(value) # b'myvalue'

In this example, we are using the redis.Redis class to connect to Redis on localhost at the default port (6379) and database (0). We are then setting a key-value pair using the set method and getting the value of the key using the get method. The b prefix indicates that the value is returned as bytes.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book
Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.