{ @Override public String decode(ByteBuf buffer) { int lineEndIndex = CodecUtils.X.findLineEndIndex(buffer); if (-1 == lineEndIndex) { return null; } Long length = (Long) DefaultRespCodec.DECODERS.get(ReplyType.INTEGER).decode(buffer); if (null == length) { return null; } // Bulk Null String if (RespConstants.NEGATIVE_ONE.equals(length)) { return null; } // Bulk Empty String if (RespConstants.ZERO.equals(length)) { return RespConstants.EMPTY_STRING; } // 真实字节内容的长度 int readLength = (int) length.longValue(); if (buffer.readableBytes() > readLength) { byte[] bytes = new byte[readLength]; buffer.readBytes(bytes); // 重置读游标为rn之后的第一个字节 buffer.readerIndex(buffer.readerIndex() + 2); return new String(bytes, RespConstants.UTF_8); } return null; }}public class RespArrayDecoder implements RespDecoder { @Override public Object decode(ByteBuf buffer) { int lineEndIndex = CodecUtils.X.findLineEndIndex(buffer); if (-1 == lineEndIndex) { return null; } // 解析元素个数 Long length = (Long) DefaultRespCodec.DECODERS.get(ReplyType.INTEGER).decode(buffer); if (null == length) { return null; } // Null Array if (RespConstants.NEGATIVE_ONE.equals(length)) { return null; } // Array Empty List if (RespConstants.ZERO.equals(length)) { return Lists.newArrayList(); } List
推荐阅读
-
23号球魁|雄鹿三大问题不解决,被淘汰只是时间问题而已,回光返照赢得G4
-
【】美股高开纳指首次突破12000点 博彩板块领涨
-
「敲响」门要守住! 昨天深夜的这两条新闻,再次给我们敲响了警
-
-
-
-
-
美食大谱|满满的奶香味,嫩嫩的口感,「蓝莓蛋挞」的做法+配方
-
菲汐布客时尚圈|一顶好看的帽子,让小姐姐们在这个秋天,温度和风度统统都有
-
谁能告诉我我到底是强迫症还是抑郁症还是有人格分裂症
-
几款实用的Android Studio 插件给你推荐一下
-
武磊|武磊赛季首球正式诞生!短短8分钟独造2球 又创造神奇纪录
-
-
今日最奇葩|虽然无梗,但也不拘束蛮配合的,硬糖少女在《青春环游记》中表现完美
-
#埃博拉疫情#人类历史上的五大病毒,各个如同死神,而且最后一个就在我们身边
-
-
-
中国移动携号转网前夕,移动出新规,8月起流量福利大放送,收获大量点赞
-
-
前有五菱后有长安,奔奔E-Star 国民版是什么套路?