This book covers the use of Redis, an in-memory database/data structure server.

open all | close all

6.4 Task queues

When handling requests from web clients, sometimes operations take more time to
execute than we want to spend immediately. We can defer those operations by putting
information about our task to be performed inside a queue, which we process later.
This method of deferring work to some task processor is called a task queue. Right now
there are many different pieces of software designed specifically for task queues
(ActiveMQ, RabbitMQ, Gearman, Amazon SQS, and others), but there are also ad hoc
methods of creating task queues in situations where queues aren’t expected. If you’ve
ever had a cron job that scans a database table for accounts that have been modified/
checked before or after a specific date/time, and you perform some operation based
on the results of that query, you’ve already created a task queue.

In this section we’ll talk about two different types of task queues. Our first queue
will be built to execute tasks as quickly as possible in the order that they were inserted.
Our second type of queue will have the ability to schedule tasks to execute at some
specific time in the future.