We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
目前支持的: #19 #76
需要增加别的驱动支持例如:Redisson 和 Spring Data Redis Redis Template
Redisson
Spring Data Redis
Redis Template
The text was updated successfully, but these errors were encountered:
redisson比较特殊一点
redisson
从 Command 中获取参数的方法是 command.getParams() 方法返回的是Object[]。 这里要说下这个Object数组。
Command
command.getParams()
Object[]
如果是命令,比如 set,get等,那么就是String类型。
String
如果是参数则是 byte[] 类型, 需要把Object 转 ByteBuf类型。这个ByteBuf有个特点,第0位是标识符00000011, 最后一位的最高位为1,例如:参数如果是 SET aaaaa ,那么参数列表为:Object["set",byte[3,a,a,a,a,a|0x7f]] , 最后一位打印二进制位:11100001 而 a的二进制却是 01100001。 所以在拿到ByteBuf类型 需要将第0位切掉,最后一位去掉高位的1。
byte[]
Object
ByteBuf
00000011
11100001
01100001
部分java代码:
for (Object val : args) { if (val instanceof ByteBuf) { ByteBuf buf = (ByteBuf) val; if (buf.hasArray()) { String data = new String(buf.array(), buf.arrayOffset() + buf.readerIndex(), buf.readableBytes(), StandardCharsets.UTF_8); sb.append(data).append(" "); } else { byte[] bytes = new byte[buf.readableBytes()]; buf.getBytes(buf.readerIndex(), bytes); try{ byte[] result = new byte[bytes.length - 1]; System.arraycopy(bytes, 1, result, 0, bytes.length - 2); result[result.length - 1] = (byte) (bytes[bytes.length - 1] & 0x7F); String data = new String(result, StandardCharsets.UTF_8); sb.append(data).append(" "); }catch (Exception e){ System.out.println(e); } } } else { sb.append(val.toString()).append(" "); } }
Sorry, something went wrong.
No branches or pull requests
目前支持的: #19 #76
需要增加别的驱动支持例如:
Redisson
和Spring Data Redis
Redis Template
The text was updated successfully, but these errors were encountered: