上QQ阅读APP看书,第一时间看更新
Getting ready
We will do this with the help of Redis, which can be installed using the following command:
$ pip3 install redis
Make sure that you run the Redis server for the connection to happen. To install and run a Redis server, refer to http://redis.io/topics/quickstart.
Then, we need to have the connection open to Redis. This can be done by adding the following lines of code to my_app/__init__.py:
from redis import Redis redis = Redis()
We can do this in our application file, where we will define the app, or in the views file, where we will use it. It is preferred that you do this in the application file because then, the connection will be open throughout the application, and the redis object can be used by just importing it where required.