1

I'm wondering what will be the best way to save the data structure of users in redis. should I use hash or string?

this is what I did:

users:$email:fname
users:$email:lname 
users:$email:username
users:$email:password

the email is the unique id (to enable future multiple servers) so I have another string that saves all the emails: emails:$email

Also I have a username:$username to store all the usernames for easy searching

Is that the way to go?

I you can point me to a good resource to see the similar data structures of say a blog site that would be wonderful!

1
  • sure, I'm trying to set a users database to allow users to register, I'm wondering what would be the best way to do that, should I use hash or string Commented Oct 21, 2013 at 7:36

1 Answer 1

1

I would use a hash object here.

While you can use strings as you proposed, it is more interesting to aggregate the various fields defining a user in a single object. With a hash, it is easier to delete, expire, retrieve a single user. It is also much more memory efficient.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.