{"id":23502976,"url":"https://github.com/0xsky/xredis","last_synced_at":"2025-04-04T18:09:56.870Z","repository":{"id":18393235,"uuid":"21574443","full_name":"0xsky/xredis","owner":"0xsky","description":"Redis C++ client, support the data slice storage, support redis cluster, thread-safe,multi-platform,connection pool, read/write separation.","archived":false,"fork":false,"pushed_at":"2024-07-02T16:52:48.000Z","size":2195,"stargazers_count":338,"open_issues_count":15,"forks_count":153,"subscribers_count":48,"default_branch":"master","last_synced_at":"2025-03-28T17:10:00.925Z","etag":null,"topics":["c-plus-plus","connection-pool","cpp","data-slice-storage","multi-platform","redis","redis-client","redis-cluster","rediscluster","thread-safe","xredis"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"swinglife/shiro_ex","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xsky.png","metadata":{"files":{"readme":"README-cn.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-07T14:52:46.000Z","updated_at":"2025-01-10T08:03:23.000Z","dependencies_parsed_at":"2025-01-15T11:11:58.671Z","dependency_job_id":"2d34e65e-4777-4040-b095-126c5b2ae588","html_url":"https://github.com/0xsky/xredis","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xsky%2Fxredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xsky%2Fxredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xsky%2Fxredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xsky%2Fxredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xsky","download_url":"https://codeload.github.com/0xsky/xredis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","connection-pool","cpp","data-slice-storage","multi-platform","redis","redis-client","redis-cluster","rediscluster","thread-safe","xredis"],"created_at":"2024-12-25T08:12:05.270Z","updated_at":"2025-04-04T18:09:56.850Z","avatar_url":"https://github.com/0xsky.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"xRedis\n======\n\nxRedis 是一个C++开发的redis客户端，是对hiredis的C++封装，提供易用的redis命令操作接口.\n\n***功能与特点：***\n* 支持数据多节点分布存储，可自定义分片规则;\n* 支持同时连接到每个分片的主从节点，支持主从读写分离;\n* 支持对每个存储节点建立连接池;\n* 支持同时连接多个数据分片集群;\n* 支持连接到官方集群，支持单个节点和多个节点\n    建立到每个节点的连接池，client端自动计算slot分布。\n    支持自动计算节点索引位置,支持REDIS集群节点变化连接自动切换;\n    当官方集群节点有添加/删除/slot分布变化时，到集群的连接池会自动更新。\n* 提供简单易用的C++接口封装，已实现大部分REDIS命令;\n* 只依赖hiredis库;\n* 多线程安全\n* 支持带密码连接;\n* 支持linux、windows平台\n \n\n### Dependencies\n\nxredis 依赖 hiredis ,  在使用xRedis前需要安装[hiredis](https://github.com/redis/hiredis/)库\n\n### Install\n\n第一步 安装libhiredis\n 在Debian系统上:\n```bash\nsudo apt-get install libhiredis-dev\n```\n\nxRedis源码安装\n```bash\ngit clone https://github.com/0xsky/xredis\ncd xredis\nmake\nsudo make install\n```\n使用说明\n```C++\n#使用 xRedisClusterClient类 访问 redis节点或是官方集群(redis cluster)\n\n#include \"xRedisClusterClient.h\"\nint main(int argc, char **argv) {\n    xRedisClusterClient redisclient;\n    # 连接到REDIS，建立大小为4的连接池，\n    # 若此节点是官方集群的成员，则会自动对集群每个主节点建立大小为4的连接池。\n    std::string passwd = \"passwd123\";\n    bool bRet = redisclient.connect(\"127.0.0.1\", 6379, passwd, 4);\n\n    RedisResult result;\n    redisclient.command(result, \"set %s %s\", \"key\", \"hello\");\n    \n    printf(\"type:%d integer:%lld str:%s \\r\\n\",\n        result.type(), result.integer(), result.str());\n\n    while (true) {\n        usleep(1000*1000*6);\n        // 定时调用 keepalive 检测断线重连接，以及集群状态变化。\n        redisclient.keepalive();\n    }\n     \n    return 0;\n}\n```\n\n更多使用示例\n使用示例 [examples]目录(https://github.com/0xsky/xredis/blob/master/examples)\n\ndemo.cpp              使用xredisclient访问单个redis节点示例\ndemo_slice.cpp        使用xredisclient访问单组多分片(节点)redis分片集群示例\ndemo_multi_slice.cpp  使用xredisclient访问多组多分片(节点)redis分片集群示例\nxredis-example.cpp    使用xredisclient 批量操作示例 \nxredis-example-Consistent-hash xredisclient使用一致性hash，自定义数据分片存储demo\n\nxRedisClusterClient_test.cpp  使用xRedisClusterClient实现简单的redis官方集群客户端示例\ncluster-cli.cpp      使用 xRedisClusterClient 实现的连接redis集群的client，支持集群节增加/删除、slot分布变化时，自动切换。\n\n/test/xredis-test.cpp   多个redis命令的使用示例\n\n### 相关文档\n\n\n### 计划\n  添加 Redis 哨兵模式支持\n\n\n##### xRedis 分片存储架构图\n![xredis](doc/xredis_0.png)\n\n[xRedis API](http://xredis.0xsky.com/)\u003cbr\u003e\n使用示例 [examples](https://github.com/0xsky/xredis/blob/master/examples) directory for some examples\u003cbr\u003e\nxRedis开源社区QQ群: 190107312\u003cbr\u003e\n\n作者: xSky\u003cbr\u003e\n博客: [xSky's Blog](https://0xsky.com/)\u003cbr\u003e\nxRedis QQ 群: 190107312\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xsky%2Fxredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xsky%2Fxredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xsky%2Fxredis/lists"}