Search code examples
spring-data-redis

Got lots of '\x00' prefix when using StringRedisTemplate


I'm putting string to redis server:

stringRedis.opsForValue().set(redisKey, email, ACTIVATION_CODE_TIMEOUT);

But I finally got '\x00\x00\x00\x00 ... my-value' in redis: enter image description here

Why is this happening?


Solution

  • Sorry about this asking. It's my fault. I made mistakes about using the set()method. The third parameter of set() method is not timeout value. It's offset. To fix it:

    stringRedis.opsForValue().set(redisKey, email, ACTIVATION_CODE_TIMEOUT, TimeUnit.SECONDS);