Home > Database > Redis > body text

Use redis database to store user information

王林
Release: 2021-02-08 09:46:01
forward
3718 people have browsed it

Use redis database to store user information

The more recommended way is to use the hash type in the redis database to store it.

Of course it is possible to use session, but there will be disadvantages. If there is only one server and use session, when multiple servers are load balanced, the session may be stored in server A and retrieved in server B, but cannot be retrieved. to, so use Redis.

The example is as follows:

Use redis database to store user information

When the user changes personal information, it is stored in Redis and put into the database. This will also cache the data and does not need to be in the database. Query again.

Use redis database to store user information

Get information

Use redis database to store user information

(Learning video sharing: redis video tutorial)

service layer

Use redis database to store user information

Test it with postman!
Register the user first, then query directly after successful registration

Use redis database to store user information

According to the user ID, query the information

Use redis database to store user information

This way There is no need to go through the database for every query. If the user updates personal information, it will be synchronized to redis
The null values ​​for phone and time here are because I did not forget to save them in redis when registering, so null values ​​appear. One is registration. , one is to change, just store the changes in redis.

Related recommendations: redis database tutorial

The above is the detailed content of Use redis database to store user information. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template