Managing User Expiration
Managing User Data with Expiration
Welcome to the first step in building our Redis-based backend system. In this unit, we will focus on how to manage user data with expiration using Redis. This is a fundamental part of our project that will set the stage for more advanced features in later units.
What You'll Build
Let's take a quick look at what you'll be building in this unit. We will focus on two key operations for managing user data:
- Adding user data with an expiration time: This will ensure that user data is stored for a limited period and is automatically deleted afterward.
- Retrieving user data: This operation will help us fetch the user data we previously stored.
Here's a quick example of how we will structure these operations:
You might remember the EX parameter from the previous lessons. It allows us to set an expiration time for the data we store in Redis. In this case, we are setting the expiration to 86400 seconds (one day) by passing "EX", "86400" to the SET command.
Notice how we chain the operations: first we execute the SET command with expiration, and once it completes successfully, we execute the GET command to retrieve the data. The ioc.run() call at the end processes all asynchronous operations until they complete.
