forked from pyb1993/JavaRedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHsetCommandHandler.java
More file actions
23 lines (20 loc) · 959 Bytes
/
HsetCommandHandler.java
File metadata and controls
23 lines (20 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package RedisCommand;
import Common.Logger;
import Common.RedisStringList;
import RedisDataBase.RedisDb;
import RedisDataBase.RedisObject;
import RedisDataBase.RedisString;
import io.netty.channel.ChannelHandlerContext;
import MessageOutput.MessageOutput;
public class HsetCommandHandler implements RedisCommandHandler<RedisStringList>{
static private final RedisString hsetConstant = new RedisString("hset");
@Override
public void handle(ChannelHandlerContext ctx, RedisString requestId, RedisStringList message){
// 执行 set key value 的命令
Logger.debug("hset recv :" + message.arr);
// todo 需要优化 new RedisString
RedisObject val = RedisObject.redisStringObject(new RedisString(message.arr.get(2)));// 需要执行
RedisDb.hset(new RedisString(message.arr.get(0)),new RedisString(message.arr.get(1)), val);
ctx.writeAndFlush(new MessageOutput(requestId,hsetConstant,"1"));
}
}