package com.ks;
|
|
import com.ks.goldcorn.GoldCornApplication;
|
import org.junit.jupiter.api.Test;
|
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.test.context.ContextConfiguration;
|
|
import javax.annotation.Resource;
|
import java.util.concurrent.TimeUnit;
|
|
@SpringBootTest(classes = GoldCornApplication.class)
|
@ContextConfiguration
|
public class RedisTest {
|
|
@Resource
|
private RedisTemplate redisTemplate;
|
|
|
@Test
|
public void getTime() throws InterruptedException {
|
String timeKey = "test-";
|
redisTemplate.opsForValue().set(timeKey, "1", 2, TimeUnit.SECONDS);
|
long time1 = (redisTemplate.getExpire(timeKey));
|
Thread.sleep(2000);
|
time1 = (redisTemplate.getExpire(timeKey));
|
Thread.sleep(2000);
|
time1 = (redisTemplate.getExpire(timeKey));
|
}
|
|
}
|