Challenge: Managing User Profiles
You need to create and manage user data using hashes in Redis. Each user is represented as a hash containing their name, age, and email.
Steps
-
Create a hash for
user:1001with the following data: name"Alice", age30, and email"alice@example.com"; -
Retrieve and verify the data for
user:1001; -
Update the age of
user:1001to31and remove their email; -
Add two new users:
user:1002(name:"Bob", age:25, email:"bob@example.com");user:1003(name:"Carol", age:29, email:"carol@example.com").
-
Retrieve the age of all users;
-
Delete users whose age is less than
28; -
Add a new field
statuswith the value"active"for the remaining users.
1. Create a hash for user:1001:
HSET user:1001 name "Alice" age 30 email "alice@example.com"
2. Retrieve and verify data from the hash user:1001:
HGETALL user:1001
3. Update data in the hash user:1001:
HSET user:1001 age 31
HDEL user:1001 email
4. Create hashes for two new users:
HSET user:1002 name "Bob" age 25 email "bob@example.com"
HSET user:1003 name "Carol" age 29 email "carol@example.com"
5. Retrieve the ages of all users:
HGET user:1001 age
HGET user:1002 age
HGET user:1003 age
6. Delete users with an age less than 28:
DEL user:1002
7. Add a new field status for the remaining users:
HSET user:1001 status "active"
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 3.33
Challenge: Managing User Profiles
Sveip for å vise menyen
You need to create and manage user data using hashes in Redis. Each user is represented as a hash containing their name, age, and email.
Steps
-
Create a hash for
user:1001with the following data: name"Alice", age30, and email"alice@example.com"; -
Retrieve and verify the data for
user:1001; -
Update the age of
user:1001to31and remove their email; -
Add two new users:
user:1002(name:"Bob", age:25, email:"bob@example.com");user:1003(name:"Carol", age:29, email:"carol@example.com").
-
Retrieve the age of all users;
-
Delete users whose age is less than
28; -
Add a new field
statuswith the value"active"for the remaining users.
1. Create a hash for user:1001:
HSET user:1001 name "Alice" age 30 email "alice@example.com"
2. Retrieve and verify data from the hash user:1001:
HGETALL user:1001
3. Update data in the hash user:1001:
HSET user:1001 age 31
HDEL user:1001 email
4. Create hashes for two new users:
HSET user:1002 name "Bob" age 25 email "bob@example.com"
HSET user:1003 name "Carol" age 29 email "carol@example.com"
5. Retrieve the ages of all users:
HGET user:1001 age
HGET user:1002 age
HGET user:1003 age
6. Delete users with an age less than 28:
DEL user:1002
7. Add a new field status for the remaining users:
HSET user:1001 status "active"
Takk for tilbakemeldingene dine!