28 lines
1.1 KiB
Java
28 lines
1.1 KiB
Java
package com.webgame.webgamebackend.common.config;
|
|||
|
|
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||
|
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
||
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||
|
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||
|
|
|
||
|
|
import java.time.Duration;
|
||
|
|
|
||
|
|
@Configuration
|
||
|
|
public class RedisConfigurer {
|
||
|
|
/**
|
||
|
|
* 创建并配置 Redis 消息监听容器
|
||
|
|
* 用于实现 Redis 的发布/订阅功能,支持监听特定频道的消息
|
||
|
|
*
|
||
|
|
* @param redisConnectionFactory Redis 连接工厂
|
||
|
|
* @return 配置好的 RedisMessageListenerContainer 实例
|
||
|
|
*/
|
||
|
|
@Bean
|
||
|
|
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory) {
|
||
|
|
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||
|
|
container.setConnectionFactory(redisConnectionFactory);
|
||
|
|
return container;
|
||
|
|
}
|
||
|
|
}
|