Open
Description
I would like to be able to SCAN keys in a cluster as in the below example code.
std::unordered_set<std::string> scan(std::string const& glob_expr)
{
std::unordered_set<std::string> result;
auto scan_node = [&](Redis& redis)
{
auto cursor = 0LL;
do {
cursor = redis.scan(cursor, glob_expr, [&](std::string const& k) { result.insert(k); });
} while (cursor != 0);
};
ShardsPool shards_pool(...);
for(auto const& slot : shards_pool->shards())
{
auto pool = shards_pool->fetch(slot.second());
auto node = Redis(std::make_shared<GuardedConnection>(pool));
scan_node(node));
}
return result;
}
The above uses the Redis::Redis(const GuardedConnectionSPtr &)
which is private, so obviously not the cleanest approach.
A better way would be to add the following RedisCluster
methods, please.
Shards RedisCluster::shards() const
{
return pool_.shards();
}
ConnectionPoolSPtr RedisCluster::fetch(const Node & node)
{
return pool_.fetch(node);
}
Thank you!
Metadata
Metadata
Assignees
Labels
No labels