This is very convenient to implement using redis. A key is used to store the number of submissions. If the key is count. Get count from redis every time you submit
If count is empty, set the count value to 1, set the timeout to one minute, and submit normally;
If the count value is not empty and is greater than or equal to 5, an error message will be reported "Operation is frequent, please enter the verification code";
If the count value is not empty and less than 5, it will be submitted normally and the count value will be increased by one.
Record the generation time of each tag If the rule is that only 4 tags can be generated in one minute, an error will be reported for the 5th one Just compare the 1st of the 4 most recent ones before adding the 5th one Is the generation time of each time, compared with the current time, greater than 60 seconds? If not, an error will be reported.
Use session to record two values, one is the number of submissions $count and the other is the submission time $time. ++$count==5 [Condition 1] is detected every time it is submitted. If so, time()-$time>=60 seconds [Condition 2]. If both conditions are met, frequent operations will be prompted. If only the condition is met 1 then $count=0;$time=time();
This is very convenient to implement using redis. A key is used to store the number of submissions. If the key is count.
Get count from redis every time you submit
If count is empty, set the count value to 1, set the timeout to one minute, and submit normally;
If the count value is not empty and is greater than or equal to 5, an error message will be reported "Operation is frequent, please enter the verification code";
If the count value is not empty and less than 5, it will be submitted normally and the count value will be increased by one.
Record the generation time of each tag
If the rule is that only 4 tags can be generated in one minute, an error will be reported for the 5th one
Just compare the 1st of the 4 most recent ones before adding the 5th one Is the generation time of each time, compared with the current time, greater than 60 seconds? If not, an error will be reported.
Use session to record two values, one is the number of submissions $count and the other is the submission time $time. ++$count==5 [Condition 1] is detected every time it is submitted. If so, time()-$time>=60 seconds [Condition 2]. If both conditions are met, frequent operations will be prompted. If only the condition is met 1 then $count=0;$time=time();
It is recommended to use redis cache operation