redis使用increment保存后,使用valueOps.get(key)获取报错

Blade 未结 4 1907
914254365
914254365 2021-05-27 11:02

一、该问题的重现步骤是什么?

1. 

.getRedisTemplate().execute(SessionCallback() {
    Object execute(RedisOperations redisOperations) DataAccessException {
        String likeKey = RedisKeyKit.(, );
        String userLikeKey = RedisKeyKit.();

        isMember = redisOperations.opsForSet().isMember(likeKey, );

        redisOperations.multi();

        (!isMember) {
            redisOperations.opsForSet().add(likeKey, );
            redisOperations.opsForValue().increment(userLikeKey);
        } {
            redisOperations.opsForSet().remove(likeKey, );
            redisOperations.opsForValue().decrement(userLikeKey);
        }

        redisOperations.exec();
    }
});

2. 

String userLikeKey = RedisKeyKit.(userId);
.getCounter(userLikeKey);

3.


二、你期待的结果是什么?实际看到的又是什么?

bladeRedis.getCounter(userLikeKey);
获取到正确得计数值

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

2.8

四、请提供详细的错误堆栈信息,这很重要。

java.lang.RuntimeException: Truncated.

at io.protostuff.IOUtil.mergeFrom(IOUtil.java:50)

at io.protostuff.ProtostuffIOUtil.mergeFrom(ProtostuffIOUtil.java:104)

at org.springblade.core.redis.serializer.ProtoStuffSerializer.deserialize(ProtoStuffSerializer.java:59)

at org.springframework.data.redis.core.AbstractOperations.deserializeValue(AbstractOperations.java:335)

at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:61)

at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228)

at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)

at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)

at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53)

at org.springblade.core.redis.cache.BladeRedis.getCounter(BladeRedis.java:280)

at vip.qichong.community.behavior.service.impl.LikesServiceImpl.userLikedCount(LikesServiceImpl.java:109)

at vip.qichong.community.behavior.service.impl.LikesServiceImpl$$FastClassBySpringCGLIB$$3ad7bb4b.invoke()

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)

五、若有更多详细信息,请在下面提供。

4条回答
  •  OrangeZh
    OrangeZh (楼主)
    2021-12-22 17:31

    bridataRedis.hIncrBy("test_key", "num", 0);
    bridataRedis.hGetAll("test_key");

    确实不行,会异常

提交回复