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

  • Redis Serialization Problems

    Hi,

    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:

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

    Code:
    '\xac\xed\x00\x05t\x00\nuser'
    and the value has become:

    Code:
    '\xac\xed\x00\x05sr\x00\x0ejava.lang.Long;\x8b\xe4\x90\xcc\x8f#\xdf\x02\x00\x01J\x00\x05valuexr\x00\x10java.lang.Number\x86\xac\x95\x1d\x0b\x94\xe0\x8b\x02\x00\x00xp\x00\x00\x00\x00\x00\x00\x00\x03'
    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.

    Comment

    Working...
    X