提交 8fea31c8 作者: 沈振路

延时客服-finish

上级 e61dd714
import com.yaoyaozw.customer.CustomerServiceApplication;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.TimeUnit;
/**
* @author darker
* @date 2022/10/19 14:42
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CustomerServiceApplication.class)
public class Test {
@Autowired
private RedisTemplate redisTemplate;
@org.junit.Test
public void testRedis() {
redisTemplate.opsForValue().set("count", 0);
redisTemplate.expire("count", 1, TimeUnit.MINUTES);
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
redisTemplate.opsForValue().increment("count");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论