title: Spring Data Cache + Redis: How to avoid storing class names in serialized JSON which waste lots of space?
body: <p>I am using Spring Data Cache using Redis as the cache manager. The config is like:</p>
  <pre><code>    return RedisCacheManager.builder(redisConnectionFactory)
          .cacheDefaults(
              RedisCacheConfiguration.defaultCacheConfig()
                  .serializeKeysWith(SerializationPair.fromSerializer(RedisSerializer.string()))
                  .serializeValuesWith(SerializationPair.fromSerializer(RedisSerializer.json()))
          )
          .build()
  </code></pre>
  <p>Let's imagine a very naive example using spring data cache:</p>
  <pre><code>@Cacheable(...)
  MyPOJO compute() { ... }
  </code></pre>
  <p>However, the <code>RedisSerializer.json()</code> is indeed a <code>GenericJackson2JsonRedisSerializer</code>. Thus, IMHO it will store things like <code>{&quot;hello&quot;:&quot;world&quot;,&quot;@class&quot;:&quot;com.my.name.some.package.MyPOJO&quot;}</code>. That <code>@class: ...</code> part is quite long and a waste of precious memory in Redis. Moreover, IMHO Spring Data Cache should be smart enough to realize that the value type is indeed <code>MyPOJO</code>, so it should not need to store that <code>&quot;@class&quot;</code>.</p>
  <p>Thus my question is: How to avoid storing class names in serialized JSON which waste lots of space, in Spring Data Cache + Redis CacheManager?</p>
  <p>Thanks for any suggestions!</p>