Announcement Announcement Module
No announcement yet.
Redis Serialization Problems Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redis Serialization Problems


    I'm putting together a PoC to see if Spring Data Redis is an appropriate solution for a certain problem. Thus far I've got A Jedis connection factory configured and can inject a working RedisTemplate where I want it.

    The problem is that I'm using a RedisTemplate<String, Long>. If I do the call:

    temp.opsForList().rightPush("user", 3L);
    When I look up what's actually been put into Redis, the key has become:

    and the value has become:

    In the case of the key, that's a bit annoying. In the case of the value, that is not a sane way of storing a Long. Is there a better way of doing the serialization?

  • #2
    As is often the case, I got impatient and just started trying things. I tried using the JacksonJson serializer, however our project uses Jackson 2.1 and the current version of Spring does not play nicely with Jackson 2.x (due to the package name changes).

    In the end I wrote my own RedisSerializer for Longs. It works for this use case since I don't have any intent to store complex data types, however I still feel like there must be a cleaner way.