forked from pyb1993/JavaRedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCommandHandler.java
More file actions
31 lines (28 loc) · 920 Bytes
/
TestCommandHandler.java
File metadata and controls
31 lines (28 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package RedisCommand;
import MessageOutput.MessageOutput;
import RedisDataBase.RedisDb;
import RedisDataBase.RedisObject;
import RedisDataBase.RedisString;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
/***处理常见的命令
* 如果key不存在,返回一个空字符串
*
* ***/
public class TestCommandHandler extends ChannelInboundHandlerAdapter {
static int allBytes = 0;
static int times = 0;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg){
// 执行 get key 的命令
ByteBuf in = (ByteBuf)msg;
times++;
allBytes += in.readableBytes();
ctx.fireChannelRead(msg);
if(allBytes >= 10000000 ){
System.out.println("共接收:" + allBytes + " byte");
}
}
}