最近遇到了一個問題,使用incr計數,存進去了一個數字(Integer類型),可是由於默認是把value(Integer類型)序列化以後存進去的,調用incr方法時候報錯了:java
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range
at redis.clients.jedis.Protocol.processError(Protocol.java:115)
at redis.clients.jedis.Protocol.process(Protocol.java:133)
at redis.clients.jedis.Protocol.read(Protocol.java:202)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210)
at redis.clients.jedis.Jedis.incrBy(Jedis.java:556)
... 81 common frames omitted
解決:存進去時直接使用set(String key,String value),不序列化value。redis