public static void main(String[] args) {
//getRedisCode("12345678901","012170");
public static void getRedisCode(String phone,String code){
Jedis jedis = new Jedis("175.178.27.250",6379);
String codeKey = "VeriCode"+phone+":code";
String redisCode = jedis.get(codeKey);
//2 每个手机每天只能发送三次,验证码放到redis中,设置过期时间
public static void verifyCode(String phone){
Jedis jedis = new Jedis("175.178.27.250",6379);
String countKey = "VeriCode"+phone+":count";
String codeKey = "VeriCode"+phone+":code";
String count = jedis.get(countKey);
jedis.setex(countKey,24*60*60,"1");
jedis.setex(codeKey,120,vcode);
}else if(Integer.parseInt(count) <= 2){
jedis.setex(codeKey,120,vcode);
}else if(Integer.parseInt(count)>2){
System.out.println("您的操作过于频繁,请稍后再试");
public static String getCode(){
int rand = random.nextInt(10);
标签:code,String,验证码,发送,codeKey,jedis,模拟 From: https://www.cnblogs.com/tanhongwei/p/16882342.html