How it works...

To use the redis-py library, first of all we need to import the module with "import redis". "redis.StrictRedis()" in line 6 of RedisDemo.py creates a StrictRedis instance that connects to the localhost Redis Server. Methods in StrictRedis can be used to send commands to the Redis Server. Most method names and their syntax are the same as the Redis commands we introduced in Chapter 2, Data Types and Chapter 3, Data Features. The few exceptions will be explained later in this recipe.

In RedisPipelineDemo.py, the pipeline() method will create a Redis pipeline instance, then we can add commands to the pipeline in the same way as when we execute commands directly. Calling execute() will send the commands to the server and return ...

Get Redis 4.x Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.