I an using redis cache and faced the problem: map with integer key is serialized as String like this:
"1":"AAAA","2":"BBB","3":"CCC"
This is how my config looks like:
@Bean
public RedisCacheConfiguration myCacheConfiguration()
{
return RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ZERO)
.disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair
.fromSerializer(new Jackson2JsonRedisSerializer<>(Map.class)));
}
@Bean
public CacheManager myCacheManager(RedisConnectionFactory redisConnectionFactory)
{
return RedisCacheManager.builder(redisConnectionFactory)
.cacheDefaults(myCacheConfiguration())
.transactionAware()
.build();
}
I tried to pass GenericJackson2JsonRedisSerializer to serializeValuesWith(), but is doesn't work. Is there any way to serialize\deserialize Integer keys of map as number?