redis 版的 hello world

为 redis 添加一个命令,效果如下图:

在 Server.h 中加入命令处理函数的声明:

void meCommand(client *c);

在 Server.c 的命令表中加入:

struct redisCommand redisCommandTable[] = {
    {"me",meCommand,1,"rF",0,NULL,0,0,0,0,0},
    ...
}

在 t_string.c 中加入命令函数的实现:

void meCommand(client *c) {
    robj *o = createStringObject("zhang", 5);
    addReplyBulk(c, o);
}
原文地址:https://www.cnblogs.com/allenwas3/p/9410922.html