March 2019
Beginner
490 pages
12h 40m
English
Basically, Redis is a tool for data structures in memory and is used as a database cache. With it, most of the data is in memory, making the request for information that's required through queries much faster.
We can create a connection to Redis from Python by using the redis-py package, where port=6379 and db=0 are default values:
>>> import redis>>> redis_client = redis.Redis(host='localhost', port=6379, db=0)>>> print(redis_client)Redis<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
Now that we are connected to Redis, we can start reading and writing data. The following instruction writes the my_value to the Redis my_key key, reads it back, and prints it:
>>> redis_client.set('my_key','my_value') True ...Read now
Unlock full access