org.springframework.dao.InvalidDataAccessApiUsageException (springboot redis操作异常)

存储的类型和获取的类型不一致

下面报错本人是使用redis演示

-----------------------------------------------------------

org.springframework.dao.InvalidDataAccessApiUsageException: WRONGTYPE Operation against a key holding the wrong kind of value; nested exceptionis redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value

----------------------------------------------------------------

数据存储类型zset

        Boolean resultKeyClient = stringRedisTemplate.opsForZSet().add(key, key + "_" + userId + "_" + ip, System.currentTimeMillis());


获取key的类型用string就会报错

String everyMaxVal = stringRedisTemplate.opsForValue().get(MobileConstrant.AUTH_EVERY_NUMBER+ clientId + "_" + goodsId);

正确获取改为zset获取就行了,操作注意就OK


版权声明:本文为linhaibing009原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。