Example of using redis database to store user information
This article shares with you an example of using a redis database to store user information. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The recommended way is to use the hash type in the redis database to store.
Of course, it is OK to use session, but there will be drawbacks. If there is only one server, session is used, and when multiple servers are load balanced, session may be stored in A server, and when it is picked up, it will be on B server, so Redis is used.
Examples are as follows:
When a user changes personal information, it is stored in Redis + put into the database, which also caches the data and does not need to be queried again in the database.
Get information
(learn video sharing: redis video tutorial)
Service layer
Test it with postman!
Register the user first, and then query directly after the registration is successful.
Query the information according to the user Id
In this way, every query does not have to go through the database. If the user updates his personal information, it will be synchronized to redis.
Here the null value of phone and time is because I didn't forget to store it in redis when I registered, so there is a null value, one is registration, the other is change, just store the change in redis.
Thank you for reading! This is the end of this article on "examples of using redis database to store user information". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!