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
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.
This kind of data won’t be persistent. It’s just for query convenience. In fact, it’s better if you have redis, really.
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
Depending on whether you need to persist the data, you can put it in redis without any need.
Generally put redis inside better, of course, if you support session, there is no problem (if you write the interface will not work).
The advantage of storing database is to facilitate data analysis and use later.
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.
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 onlyid.net.