Article From:

Is the SMS verification code sent to the database stored or stored in session when the system is registered? Now the company’s practice is in the database, but I think it is very wasteful, producing a lot of waste data, and there is a problem that may save the database after the message is sent out. Image validation codeIs the direct storage of session, general business applications will be used to send SMS records? It’s not too much to use

Answer 0:

1:If your system does not use a cache like redis now, and the system’s registered user visits, and the foreseeable future registered users are not very high (registration is not a very frequent operation), can be placed in the session, otherwise it is recommended to be placed in the cache.
2:If the system already has a cache like redis, put it in the cache.

Answer 1:

Put redis

Answer 2:

This kind of data won’t be persistent. It’s just for query convenience. In fact, it’s better if you have redis, really.

Answer 3:

SMS verification code usually has an expiration time, such as 5 minutes.
1、redisThe perfect support for data aging characteristics
2、Checking value performance according to key

Answer 4:

Depending on whether you need to persist the data, you can put it in redis without any need.

Answer 5:

Generally put redis inside better, of course, if you support session, there is no problem (if you write the interface will not work).

Answer 6:

The advantage of storing database is to facilitate data analysis and use later.

Answer 7:

It’s very obvious that it should be cached, and it’s most reasonable to put it in redis, because the verifying code is valid for ten minutes to thirty minutes, and there is no use in time. It’s a waste of space and the pressure of the database (because it doesn’t need to be saved for a long time); you put it.Redis only needs to set an expired time for him to expire. This key is gone, which is invalid and convenient to judge.

Answer 8:

Many people upstairs said to deposit redis, and I disagree: unless the owner of the building has other business needs to build redis, there is no need to build redis specifically for the sake of depositing verification codes.
If you save session, you can actually see the implementation of session, such as the implementation of many nodejs session.
What I suggest: how to save how to save, save the database without any problem, say increase the pressure of the database, in fact, most of the domestic company projects, far from the bottleneck of the database. Especially small projects in the early stage. On the contrary, the efficiency of development is precious.

You can also try some integrated mobile phone number verification service, which is also very convenient, such as

Leave a Reply

Your email address will not be published. Required fields are marked *