My default setting for users is a serialized object in the standard u: userid key - this object gets access to each request, and access to only one of the properties is never required.
You can also use a hash rather than json for user properties, but my setup includes everything that is used as strongly typed objects and redis runs on a different server from the client, so using json simplifies the use of general deserialization and minimizes any delay problems .
In addition to the user object itself, you will need an index for any fields that you must use to search for the user - for example, to allow the user to log in with an email address, you will need the key e: email => User ID. The hash will also work here - the important thing is that you need something that is O (1) in order to receive from email to the user object.
Sometimes parts of user data must have their own keys - for example, a list of followers is ideal for redis, so it's best to store it in this form.
Tom clarkson
source share