【问题标题】:Predis using PHP: How to get which Redis node ( host ) that holds a particular key?Predis 使用 PHP:如何获取持有特定密钥的 Redis 节点(主机)?
【发布时间】:2017-06-06 04:34:20
【问题描述】:

我在 PHP 中使用 Predis 使用 Redis 集群,我做的很简单

$image_urls = $client->get($key)

现在我想获取 Redis 找到键值对的主机地址,因为它还包含本地图像,我需要获取这些图像的完整链接。

【问题讨论】:

    标签: php codeigniter redis predis redis-cluster


    【解决方案1】:

    您可以使用getConnectionByKey() 获取该信息。

    例如:

    $cluster = new PredisCluster();
    $cluster->add($connection);
    $cluster->add($connection2);
    $connection = $cluster->getConnectionByKey($key);
    

    来源:PredisClusterTest.php

    【讨论】:

    • 非常感谢马克!
    猜你喜欢
    • 2016-05-14
    • 2015-09-15
    • 2017-09-18
    • 2013-10-06
    • 2021-08-24
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多