/redis-server

Redis Server in C++

Primary LanguageCMIT LicenseMIT

Author Platform NoSQL License

###中文说明 xredis-server

redis-server is a redis server framework library write by C++, using this library you can develop redis protocol compatible server easily.

Dependencies

xredis-server requires libevent

###install

git clone https://github.com/0xsky/xredis-server.git
cd xredis-server
make

###build example

make example

###usage:

#include "../src/xRedisServerLib.h"

class RedisConnect :public RedisConnectorBase
{
public:
    RedisConnect();
    ~RedisConnect();
private:
};

class RedisServer :public RedisServerBase
{
public:
    RedisServer() {

    }
    ~RedisServer() {

    }

public:
    bool Init()
    {
        CmdRegister();
    }

private:
    bool CmdRegister()
    {
        if (!SetCmdTable("get", (CmdCallback)&RedisServer::ProcessCmd_get)) return false;
        return true;
    }

    void ProcessCmdGet(RedisConnect *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)
{
    RedisServer xRedis;
    xRedis.Init();
    std::string pass = "123456";
    xRedis.SetPassword(pass);
    xRedis.Start("127.0.0.1", 6479);

    while (1) {
        usleep(1000);
    }
    
    return 0;
}

DOC

example [examples](https://github.com/0xsky/xredis-server/tree/master/example) directory for some examples

QQ Group: 190107312

author: xSky

Blog: xSky's Blog