Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

xredis-server 1.0 发布,Redis 服务器框架库

$
0
0

xredis-server 1.0 发布了。 xredis-server 是一个C++开发的redis服务器框架库,使用这个库可以很容易的开发自己的redis协议兼容服务器。

实现Redis服务端协议,支持auth认证命令.

example:

#include "../src/xRedisServerLib.h" class xRedisConnect :public xRedisConnectorBase { public: xRedisConnect(); ~xRedisConnect(); private: }; class xRedisServer :public xRedisServerBase { public: xRedisServer() {} ~xRedisServer() {} public: bool Init() { CmdRegister(); } private: bool CmdRegister() { if (!SetCmdTable("get", (CmdCallback)&xRedisServer::ProcessCmd_get)) return false; return true; } void ProcessCmd_get(xRedisConnect *pConnector) { if (2 != pConnector->argc) { SendErrReply(pConnector, "cmd error:", "error arg"); return; } SendBulkReply(pConnector, pConnector->argv[1]); return; } private: }; int main(int argc, char **argv) { xRedisServer xRedis; xRedis.Init(); std::string pass = "123456"; xRedis.SetPassword(pass); xRedis.Start("127.0.0.1", 6479); while (1) { usleep(1000); } return 0; }

Viewing all articles
Browse latest Browse all 6262

Trending Articles