1.redis_pipeline=redis_cli.pipeline()
2.redis_pipeline.setex()此语句可写多条
3.redis_pipeline.execute()
# # 2.2将随机数保存在redis中
# redis_cli.setex('sms_' + mobile, constants.SMS_CODE_EXPIRES, sms_code)
#
# # 2.3将发送标记保存在redis中
# redis_cli.setex('sms_flag_' + mobile, constants.SMS_FLAG_EXPIRES, 1)
# 2.2,2.3的优化,只与redis交互一次
redis_pipeline = redis_cli.pipeline()
redis_pipeline.setex('sms_' + mobile, constants.SMS_CODE_EXPIRES, sms_code)
redis_pipeline.setex('sms_flag_' + mobile, constants.SMS_FLAG_EXPIRES, 1)
redis_pipeline.execute()