Advertisement

Redis key expiration monitoring in Spring Boot 2

阅读量:

1、调整Redis配置参数

将注释符号 # notify-keyspace-events Ex 前的标记删除,随后执行redis服务的重启操作

需特别注意的是,Ex参数应当使用双引号进行包裹

2、在pom文件中增加相应配置

复制代码
    <dependency>

    
         <groupId>org.springframework.boot</groupId>
    
         <artifactId>spring-boot-starter-data-redis</artifactId>
    
     </dependency>
    
    
    
    
    AI写代码html

3、引入redis监听机制

复制代码
 package com.example.demo.redis;

    
  
    
 import org.springframework.beans.factory.annotation.Autowired;
    
 import org.springframework.data.redis.connection.Message;
    
 import org.springframework.data.redis.connection.MessageListener;

全部评论 (0)

还没有任何评论哟~