package shop.alien.lawyer.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

/**
 * Redis Key過期監聽配置
 * 
 * @author system
 * @since 2025-01-XX
 */
@Slf4j
@Configuration
public class RedisKeyExpirationConfig {

    /**
     * 配置Redis消息監聽容器，用於監聽key過期事件
     * 
     * @param connectionFactory Redis連接工廠
     * @return Redis消息監聽容器
     */
    @Bean
    public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        log.info("Redis Key過期監聽容器初始化完成");
        return container;
    }
}

