整理代码

20230922-ljl-fixBug
laixiongwei 1 year ago
parent 6745853f5d
commit 0a21cb9821

@ -23,10 +23,10 @@
<dependencies>
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!-- </dependency>-->
<!--es-->
<dependency>

@ -15,21 +15,24 @@ import java.util.concurrent.TimeUnit;
*/
@Slf4j
//@Component
public class RedisDemoService implements ApplicationListener<ContextRefreshedEvent> {
@Autowired
private RedisTemplate<String, String> redisTemplate;
public class RedisDemoService {
private static final String DEBUG_KEY = "ContextRefreshedEventTime";
public void setKey() {
redisTemplate.opsForValue().set(DEBUG_KEY, String.valueOf(System.currentTimeMillis()), 1, TimeUnit.MINUTES);
String value = redisTemplate.opsForValue().get(DEBUG_KEY);
log.info("RedisDemoService get value:" + value);
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
setKey();
}
}
//public class RedisDemoService implements ApplicationListener<ContextRefreshedEvent> {
// @Autowired
// private RedisTemplate<String, String> redisTemplate;
//
// private static final String DEBUG_KEY = "ContextRefreshedEventTime";
//
// public void setKey() {
// redisTemplate.opsForValue().set(DEBUG_KEY, String.valueOf(System.currentTimeMillis()), 1, TimeUnit.MINUTES);
//
// String value = redisTemplate.opsForValue().get(DEBUG_KEY);
// log.info("RedisDemoService get value:" + value);
// }
//
// @Override
// public void onApplicationEvent(ContextRefreshedEvent event) {
// setKey();
// }
//}

Loading…
Cancel
Save