在代码里对一个值为long类型key执行incrby操作,一直都正常,突发一例异常:
Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210) at redis.clients.jedis.Jedis.incrBy(Jedis.java:556) at com.xxx.xxxxxClient.incrBy(SingleJedisClientImpl.java:119) ... 19 common frames omitted
其中com.xxx.xxxxxClient.incrBy是jedis客户端的一个封装和管理。应该是xxxxxClient这里出了问题。再或者是jedis本身线程池管理出了问题。
----------------以下是网上资料,转自http://mengkang.net/443.html---------------------------------------
Caused by: java.lang.ClassCastException: [B cannot be cast to java.util.List at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:218) at redis.clients.jedis.Connection.getMultiBulkReply(Connection.java:211) at redis.clients.jedis.Jedis.lrange(Jedis.java:862) at me.topit.site.util.redis.CacheClientBase.lrange(CacheClientBase.java:516) at me.topit.site.cache.TagCache.get(TagCache.java:37) at me.topit.site.model.Tags.getUserSelectedTags(Tags.java:141) at me.topit.site.service.FeedService.getType(FeedService.java:41) 或者 Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to [B at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:201) at redis.clients.jedis.Connection.getBulkReply(Connection.java:190) at redis.clients.jedis.Jedis.hget(Jedis.java:601) at me.topit.site.util.redis.CacheClientBase.hget(CacheClientBase.java:51) at me.topit.site.cache.AccountCache.getAuth(AccountCache.java:30) at me.topit.site.model.Account.getAuth(Account.java:137) at me.topit.site.service.AccountService.loginCheck(AccountService.java:112) at me.topit.site.service.BaseService.isLogin(BaseService.java:87) at me.topit.site.service.PushService.bind(PushService.java:53)
后来发现是因为我做了redis 连接的线程池,使用的一直是一个在父类里申明的静态变量,各个地方调,都是直接用.使用完之后也没有释放.所以每次项目跑着跑着,过几个小时就访问超级慢.最后发现是因为使用的是一个连接的原因. 现在改为每次使用都先初始化,然后每次用完之后都释放.
------------------------------------------------------------------------------------------------------------
可能是作者提到的这个原因。未确认。
时间: 2024-10-08 12:24:36