update 优化 RedisUtils 重构过期方法

This commit is contained in:
疯狂的狮子Li
2022-04-30 22:21:49 +08:00
parent f32813951f
commit e18cf51c01
8 changed files with 26 additions and 28 deletions

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.TimeUnit;
import java.time.Duration;
/**
* spring-cache 演示案例
@ -87,7 +87,7 @@ public class RedisCacheController {
@GetMapping("/test6")
public R<Boolean> test6(String key, String value) {
RedisUtils.setCacheObject(key, value);
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10));
System.out.println("***********" + flag);
try {
Thread.sleep(11 * 1000);