In my app, I set my users information like:
set users:alex:age 30
set users:alex:heigth 1.8
set users:sly:age 32
set users:sly:heigth 1.95
Is there a way to get the list of users (alex, sly) without using a Set Or do I need to use a Set like:
sadd users users:alex
sadd users users:sly
and get the users with
smembers users
?
Using a set is the proper way to do it. You can also use keys users:*:age to get all users, but that would be much slower.
Also, instead of using users::age, users::height, you should use a hash in users: with “age” and “height” as keys.