package com.ping.study.utils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import java.time.Duration; @Component @Slf4j public class RedisUtil { @Autowired private RedisTemplate stringRedisTemplate; public boolean redisTemplateT(String email,String code) { //log.info("验证码:{}",code); return stringRedisTemplate.opsForValue().setIfAbsent(email, code, Duration.ofSeconds(60*5)); } }