shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.iplatform.chat.config;
 
import com.iplatform.chat.ChatSessionCache;
import com.iplatform.chat.cache.RedisChatSessionCache;
import com.iplatform.chat.service.ChatDialogServiceImpl;
import com.iplatform.core.PlatformConfiguration;
import com.walker.support.redis.RedisHelper;
import com.walker.support.redis.cache.RedisCacheProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
@ConditionalOnProperty(prefix = "iplatform.cache", name = "redis-enabled", havingValue = "true", matchIfMissing = false)
@ConditionalOnClass({RedisCacheProvider.class})
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisChatCacheConfig extends PlatformConfiguration {
 
    @Bean
    public ChatSessionCache chatSessionCache(RedisHelper redisHelper, ChatDialogServiceImpl chatDialogService){
        RedisChatSessionCache cache = new RedisChatSessionCache();
        cache.setRedisHelper(redisHelper);
        cache.setChatDialogService(chatDialogService);
        return cache;
    }
}