#spring #redis #spring-data-mongodb #redisson
Вопрос:
Поэтому я добавил редиссон в свое приложение. Конфигурация выглядит так, как определено здесь: https://pamesh12.github.io/spring-boot/spring-cache-redis.html
Конфигурация одного сервера: адрес: «redis://127.0.0.1:6379»
Когда я пытаюсь добавить кэшируемый в метод, вызывающий внешние службы с помощью RestTemplate, я вижу кэш результатов в redis-cli. Хотя, когда я пытаюсь добавить кэшируемые методы обслуживания, которые вызывают базовый репозиторий Mongo, я получаю исключение IllegalArgumentException
Может ли кто — нибудь объяснить, если это потому, что его не поддерживают? Я точно не помню, но видел, что это поддерживается только в версии pro. И если есть какие-либо альтернативы, которые я мог бы рассмотреть без особых изменений кода.
ERROR com.controller.support.ExceptionController [http-nio-9006-exec-5]: [java.lang.IllegalArgumentException] with error Id, error code and message [[org.redisson.command.CommandAsyncService.encodeMapValue(CommandAsyncService.java:743), org.redisson.RedissonObject.encodeMapValue(RedissonObject.java:305), org.redisson.RedissonMap.fastPutOperationAsync(RedissonMap.java:1375), org.redisson.RedissonMap.fastPutAsync(RedissonMap.java:1365), org.redisson.RedissonMap.fas...
@Cacheable("ratings") //cacheManager = "redisCacheManager")
public List<Entity> filterByRating(List<String> vendor/*, Pageable pageable*/) {
return ratingsRepo.findByIdIn(vendor/*, pageable*/);
}
Конфигурация:
@Конфигурация
публичного класса RedissonSpringDataConfig {
@Bean
public RedissonConnectionFactory
redissonConnectionFactory(RedissonClient redisson) {
return new RedissonConnectionFactory(redisson);
}
@Bean(destroyMethod = "shutdown")
public RedissonClient
redisson(@Value("classpath:redission/redisson-dev.yaml") Resource configFile)
throws IOException {
Config config = Config.fromYAML(configFile.getInputStream());
return Redisson.create(config);
}
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redissonConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redissonConnectionFactory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
return template;
}
@Bean(name = "redisCacheManager")
public CacheManager redisCacheManager(RedissonClient redissonClient) throws IOException {
//String configFileName = "cache-config-" activeProfile ".yml";
return new RedissonSpringCacheManager(redissonClient);
}
}
Комментарии:
1. Пожалуйста, добавьте полную трассировку стека «Исключение IllegalArgumentException».
2. добавлены подробности спасибо