我是靠谱客的博主 昏睡小白菜,最近开发中收集的这篇文章主要介绍报错JedisDataException: ERR wrong number of arguments for ‘rpop‘ command,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
报错JedisDataException: ERR wrong number of arguments for ‘rpop’ command
//取单条
String str = redisTemplate.opsForList().rightPop(CACHE_KEY);
//取多条
List<String> list = redisTemplate.opsForList().rightPop(CACHE_KEY, 5);
Springboot使用Redis使用opsForList().rightPop取单条的时候是正常的,取多条的时候报错如下:
redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'rpop' command
at redis.clients.jedis.Protocol.processError(Protocol.java:142) ~[jedis-3.8.0.jar:na]
at redis.clients.jedis.Protocol.process(Protocol.java:176) ~[jedis-3.8.0.jar:na]
at redis.clients.jedis.Protocol.read(Protocol.java:230) ~[jedis-3.8.0.jar:na]
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:352) ~[jedis-3.8.0.jar:na]
at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:304) ~[jedis-3.8.0.jar:na]
at redis.clients.jedis.BinaryJedis.rpop(BinaryJedis.java:1702) ~[jedis-3.8.0.jar:na]
at org.springframework.data.redis.connection.jedis.JedisInvoker.lambda$just$5(JedisInvoker.java:130) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisConnection.lambda$doInvoke$2(JedisConnection.java:181) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisConnection.doWithJedis(JedisConnection.java:824) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisConnection.doInvoke(JedisConnection.java:165) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisConnection.lambda$new$0(JedisConnection.java:74) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisInvoker$Synchronizer.invoke(JedisInvoker.java:1018) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisInvoker.just(JedisInvoker.java:130) ~[spring-data-redis-2.7.5.jar:2.7.5]
at org.springframework.data.redis.connection.jedis.JedisListCommands.rPop(JedisListCommands.java:284) ~[spring-data-redis-2.7.5.jar:2.7.5]
问题原因是redis版本小于6.2时并不支持该语法,而我本地的redis是3.05版本的。只有redis的版本大于等于6.2时,才支持rightPop(key, count)和leftPop(key, count),不然就只支持单条取的rightPop(key)和leftPop(key)了。
最后
以上就是昏睡小白菜为你收集整理的报错JedisDataException: ERR wrong number of arguments for ‘rpop‘ command的全部内容,希望文章能够帮你解决报错JedisDataException: ERR wrong number of arguments for ‘rpop‘ command所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复