Results 1 to 2 of 2

Thread: Redis Serialization Problems

  1. #1
    Join Date
    Aug 2012
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2012
    Posts
    5

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •