package com.cf.imes.module.system.dal.redis.listener;

import com.cf.imes.framework.mq.redis.core.pubsub.AbstractRedisSimpleMessageListener;
import com.cf.imes.framework.redis.constants.RedisKeyConstants;
import com.cf.imes.module.system.util.locale.DictDataI18nCacheUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.stereotype.Component;

/**
 * system DICT_DATA_I18N_CACHE_REFRESH redis监听器
 *
 * @author Gqr
 * @since 2024/6/13 10:32
 */
@Component
@Slf4j
public class SystemDictDataI18nCacheRefreshRedisListener extends AbstractRedisSimpleMessageListener {


    public SystemDictDataI18nCacheRefreshRedisListener() {
        super.setTopic(new ChannelTopic(RedisKeyConstants.DICT_DATA_I18N_CACHE_REFRESH));
    }

    @Override
    public void onMessage(Message message, byte[] bytes) {
        log.info("[SystemDictDataI18nCacheRefreshRedisListener][onMessage][{}收到刷新本地字典数据国际化缓存]", message);
        DictDataI18nCacheUtils.clearCache();
    }
}
