Job status cache with Redis

Now that we've introduced Redis and the Redis client for Go, let's quickly add the feature of job status to our previously designed asynchronous API. We need to make the following changes to that project:

  1. Add a new route to collect the job ID from a client
  2. Add a new handler to fetch the job status from Redis
  3. Whenever someone adds a new job, we need to write status to Redis in every stage of the job life cycle

We'll create a new project for this feature. It has a similar structure to longRunningTaskV1, which we created previously. The code and files are the same. You can clone the project and rename it longRunningTaskV2.

Let's take a look at the implementation, which includes dependency installs and modifications ...

Get Hands-On RESTful Web Services with Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.