一、异常描述
通过jedis存储内容redis内存数据库时报出“redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'set' command”,详细内容日志如下
redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'set' command@b@ at redis.clients.jedis.Protocol.processError(Protocol.java:115)@b@ at redis.clients.jedis.Protocol.process(Protocol.java:133)@b@ at redis.clients.jedis.Protocol.read(Protocol.java:202)@b@ at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)@b@ at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:184)@b@ at redis.clients.jedis.Jedis.set(Jedis.java:3197)@b@ at com.xwood.publisher.util.JedisUtil.set(JedisUtil.java:66)@b@ at com.xwood.publisher.util.JedisUtil.setEncode(JedisUtil.java:48)@b@ at com.xwood.publisher.master.ContentFolderProcesserHandler.cache(ContentFolderProcesserHandler.java:63)@b@ at com.xwood.publisher.master.AbstractProcesserHandler.run(AbstractProcesserHandler.java:26)@b@ at com.xwood.publisher.master.MasterProcesserHandler.init(MasterProcesserHandler.java:114)@b@ at com.xwood.publisher.master.MasterProcesserHandler.run(MasterProcesserHandler.java:68)@b@ at com.xwood.publisher.master.MasterProcesserHandler.main(MasterProcesserHandler.java:320)
二、解决办法
通过JedisUtil工具类的set方法“String redis.clients.jedis.Jedis.set(String key, String value, String nxxx)”详细设置如下
JedisUtil.getclient().set(key, value,"999999999999");
修改如下所示,问题就解决了
JedisUtil.getclient().set(key, value);