Storing messages
The messages we want our application to display need to be temporary. We could use a relational database for this, such as PostgreSQL, but that would mean having to design and maintain a database for something as simple as text.
An introduction to Redis
Redis is an in-memory data store. The entire dataset can be stored in memory making reads and writes much faster than relational databases, which is useful for data that is not going to need persistence. In addition, we can store data without making a schema, which is fine if we are not going to need complex queries. In our case, we simply need a data store that will allow us to store messages, get messages, and expire messages. Redis fits our use case perfectly!
Starting a Redis container
In your terminal, execute the following:
$ docker run -d -p 6379:6379 --name redis redis
This will start a Redis container with the following setup:
-d
: Specifies we want to run the container in daemon mode (background process).-p
: Allows us to...