小智 13
我已付出了fictorial redis的-CPLUSPLUS客户端,使其兼容的Redis服务器2.0版,添加缺少的API调用和执行一致性哈希.也有高层次类,这将是可用好像在不久的将来STL类型(shared_string,shared_int,shared_set,...)的早期状态.什么都没有生产就绪,但提供的测试成功运行:-)
http://github.com/mrpi/redis-cplusplus-client
小智 5
https://github.com/brianwatling/redispp
我刚刚在github上发布了我的c ++ redis客户端。现在它的主要功能是流水线化,我将很快添加更多功能,接下来可能进行分片/一致哈希处理。
C ++客户端的正式列表
探索一个完整列表的Redis的C ++客户端上redis.io。您将在其中找到基于boost,Qt等的不同客户端。请注意,此时,所有C ++客户端实现均未标记为“推荐”。但是有一个推荐的C客户端hiredis,它在C ++中应该可以正常工作。
我写了一个 C++ Redis 客户端:redis-plus-plus。它基于hiredis,并用C++11 编写。它支持以下功能:
它非常快,并且易于使用。如果您对此客户端有任何问题,请随时告诉我。如果您喜欢,也请随意加星标:)
#include <sw/redis++/redis++.h>
using namespace sw::redis;
try {
Redis redis("tcp://127.0.0.1:6379");
redis.set("key", "val");
auto val = redis.get("key");
if (val) {
// dereference val to get the value of string type.
std::cout << *val << std::endl;
} // else key doesn't exist.
redis.rpush("list", {"a", "b", "c"});
std::vector<std::string> list;
redis.lrange("list", 0, -1, std::back_inserter(list));
// put a vector<string> to Redis list.
redis.rpush("another-list", list.begin(), list.end());
auto tx = redis.transaction();
auto tx_replies = tx.incr("num0")
.incr("num1")
.mget({"num0", "num1"})
.exec();
auto redis_cluster = RedisCluster("tcp://127.0.0.1:7000");
// RedisCluster has similar interface as Redis.
redis_cluster.set("key", "value");
val = redis_cluster.get("key");
} catch (const Error &err) {
// error handling.
}
Run Code Online (Sandbox Code Playgroud)
检查文档了解详细信息。