February 2018
Intermediate to advanced
456 pages
9h 56m
English
First, let's create a new folder named dependencies inside of our temp_messenger folder. Inside, place a new file, redis.py. We will now create a Redis client with a simple method that will get a message, given a key:
from redis import StrictRedis
class RedisClient:
def __init__(self, url):
self.redis = StrictRedis.from_url(
url, decode_responses=True
)
We start off our code by implementing the __init__ method, which creates our Redis client and assigns it to self.redis. StrictRedis that can take a number of optional arguments, however, we have only specified the following:
Read now
Unlock full access