# redis-client **Repository Path**: qqsskk/redis-client ## Basic Information - **Project Name**: redis-client - **Description**: 从开源产品中拉过过来的redis客户端,并对Windows进行支持 - **Primary Language**: C/C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2020-06-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #更改说明 1.依赖项目(githup中跨平台hiredis版本) git clone https://github.com/redis/hiredis.git [ps:编译依赖需要cmake] 2.编译使用了静态的c++库,如果需要动态的需要下载项目重新编译改变下项目编译方式 右键项目 属性=>c++=>代码生成=>运行库 3.windows下使用vs2015编译出来的hiredis 静态库,Linux使用gcc version 7.4.0编译出来的库,如果需要降低版本可自行重新编译 4.windows/linux下均使用了静态链接库的方式链接hiredis库,其它方式可自行修改 5.增加通过哨兵群组ip:port初始化的接口功能 # Description - Only two files included. One hpp file and one cpp file. - Depend on hiredis. - Support both single node mode and cluster mode. - Support pipeline. - Use connection pool. - Thread safe. - Reconnect automatically. - Do not support windows yet. Find a read-write lock to replace the 'pthread_rwlock_t' if you want to use this on windows:) - (Thanks for the Brian's help.) # TODO - Optimize the reconnect function. - Support pub/sub and transaction. - Support scan in an unsafe way. # License This program was written by Shawn XU and is released under the BSD license. # Usage ```c++ #include "RedisClient.hpp" int main() { CRedisClient redisCli; if (!redisCli.Initialize("127.0.0.1", 6379, 2, 10)) { std::cout << "connect to redis failed" << std::endl; return -1; } std::string strKey = "key_1"; std::string strVal; if (redisCli.Get(strKey, &strVal) == RC_SUCCESS) { std::cout << "key_1 has value " << strVal << std::endl; return 0; } else { std::cout << "request failed" << std::endl; return -1; } } ``` You can view the test file if you want to know more using details about this client.