Middle
Have you worked with Redis? What is it used for and what type of database does it belong to?
sobes.tech AI
Answer from AI
Redis is a high-performance in-memory database that stores data in RAM for very fast processing. It is commonly used as a cache, message broker, counter, user sessions, and for storing temporary data.
Redis belongs to the NoSQL database type, more specifically — key-value stores. It supports various data structures: strings, lists, sets, hashes, sorted sets, and others.
Example of using Redis for caching query results:
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
# Save a value with the key 'user:1'
r.set('user:1', 'Ivan')
# Retrieve the value by key
name = r.get('user:1')
print(name.decode('utf-8')) # Outputs: Ivan