oklizz

  1. 提取、校验 send_flag
send_flag = redis_conn.get(\'send_flag_%s\' % mobile)
if send_flag:
    return http.JsonResponse({\'code\': RETCODE.THROTTLINGERR, 
                              \'errmsg\': \'发送短信过于频繁\'})
  1. 重新写入send_flag
# 保存短信验证码
# 短信验证码有效期,单位:秒
# SMS_CODE_REDIS_EXPIRES = 300
redis_conn.setex(\'sms_code_%s\' % mobile, 
                 constants.SMS_CODE_REDIS_EXPIRES, 
                 sms_code)

# 重新写入send_flag
# 60s内是否重复发送的标记
# SEND_SMS_CODE_INTERVAL = 60(s)
redis_conn.setex(\'send_flag_%s\' % mobile, 
                 constants.SEND_SMS_CODE_INTERVAL, 
                 1)

分类:

技术点:

相关文章:

  • 2022-01-21
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-06-25
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2021-06-25
  • 2021-05-27
  • 2021-07-28
  • 2021-04-25
相关资源
相似解决方案