Open
Description
In the AI embedding scenario, it is expected to set messages in MsgPack format to reduce server memory usage. Therefore, it is considered to replace the existing RedisTemplate creation in the following way. Is this feasible?
@Bean(name = "redisOmTemplate")
@Primary
public RedisTemplate<?, ?> redisTemplate(JedisConnectionFactory connectionFactory) {
RedisTemplate<?, ?> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setDefaultSerializer(new StringRedisSerializer());
template.setConnectionFactory(connectionFactory);
return template;
}
=>
@Bean(name = "redisOmTemplate")
@Primary
public RedisTemplate<?, ?> redisTemplate(JedisConnectionFactory connectionFactory) {
RedisTemplate<?, ?> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
template.setValueSerializer(serializer);
template.setHashValueSerializer(serializer);
return template;
}
Metadata
Metadata
Assignees
Labels
No labels