Building our Redis module
Before we write any code for our Redis module, we must understand the problem that we are trying to solve with our Redis module. Allowing a token to make authenticated requests with no expiration can be dangerous. If a hacker gets hold of the token, then there will be no limit to the requests that they can make. To solve this, we are going to use a cache that caches user login sessions. Each user login session will have a datetime of when the session was last interacted by. When we update the user session, we will increase a counter by one, and update the last interact by field to the time of the update. If the difference between the update and the last interacted by exceeds a cut off, the cache we have a time out. If the counter exceeds a cut off, we have a suggestion that the token needs refreshing. We could bake the expiry time into the token. It would be a simple solution, however, not only does building a user session cache teach us about caching, it also...