GithubHelp home page GithubHelp logo

r3c's Introduction

Redis Cluster C++ Client, based on hiredis, support password and standalone, it's easy to make and use, not depends on C++11 or later.
r3c::CRedisClient is not thread safe, you can use __thread to create a object of r3c::CRedisClient for every thread.

r3c基于redis官方的c库hiredis实现,全称是redis cluster C++ client,支持redis cluster,支持密码访问。非线程安全,GCC环境可以使用__thread为每个线程创建一个r3c::CRedisClient实例。

编译链接r3c时,默认认为hiredis的安装目录为/usr/local/hiredis,
但可以在执行make时指定hiredis安装目录,如假设hiredis安装目录为/tmp/hiredis:make HIREDIS=/tmp/hiredis,
或修改Makefile中变量HIREDIS的值来指定hiredis实现的安装目录。

编译r3c成功后,将生成libr3c.a静态库,没有共享库被生成。
也可以直接将r3c.h和r3c.cpp两个文件加入到自己项目代码中一起编译,而不独立编译r3c。

r3c_cmd.cpp是r3c的非交互式命令行工具(command line tool),具备redis-cli的一些功能,但用法不尽相同,将逐步将覆盖redis-cli的所有功能。
r3c_test.cpp是r3c的单元测试程序(unit test),执行make test即可。

编译r3c(Compile r3c):
make
或(or)
make HIREDIS=/tmp/hiredis

安装(PREFIX指定安装目录,如果不指定则为/usr/local):
make install
或(or)
make install PREFIX=/usr/local/r3c

执行单元测试:
make test
或(or)
make test REDIS_CLUSTER_NODES=192.168.1.31:6379,192.168.1.31:6380

生成源代码间的依赖:
make dep

关于接口:
如果传给CRedisClient的nodes参数为单个节点字符串,如192.168.1.31:6379则为单机模式,为多节点字符串时则为Redis Cluster模式。

性能测试工具:
https://github.com/eyjian/mooon/blob/master/mooon/tools/r3c_stress.cpp

单机性能数据:
r3c_stress --redis=192.168.0.88:6379 --requests=100000 --threads=20 
set:
microseconds=18867143, milliseconds=18867, seconds=18
total: 2000000, success: 2000000, failure: 0
qps: 111111

get:
microseconds=16063882, milliseconds=16063, seconds=16
total: 2000000, success: 2000000, failure: 0, not exists: 0
qps: 125000

hset:
microseconds=16134011, milliseconds=16134, seconds=16
total: 1999992, success: 1999992, failure: 0
qps: 124999

hget:
microseconds=15249201, milliseconds=15249, seconds=15
total: 2000000, success: 2000000, failure: 0, not exists: 0
qps: 133333

r3c's People

Contributors

eyjian avatar raymonzhong avatar jzh800 avatar tianxingpan avatar

Watchers

skyformat99 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.