2011-02-07 06:19

使用PHP连接到Redis To Go


I am a newbie with Redis...I just recently picked up Redisent to work with Redis in PHP...and I am having tons of fun! However, I signed up for the Redis to go service, and have been beating my head to connect to use the service...

The URI string is as follows:


The Redisent client simply takes in the hostname and the port...and there's no place for me to enter the username/password... :-/ I've been fiddling around with the fsockopen() function, too...but no score.

Has anyone tried connecting to Redis to go with PHP? If so, any insights or pointers would be greatly appreciated!

Note: I realize that there is a REST API available, but that's for provisioning instances, not for the actual operations such as GET/SET,etc.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongtiaobeng7901 dongtiaobeng7901 10年前

    predis is the prefered library(active development => 6 Januari 2011) to use.


    Then you need the following code to get it working(I tested it):

    $redis   = new Predis\Client('redis://$z');
    echo $redis->get('counter');
    echo "

    The strange thing is $x. It is not needed at all?

    点赞 评论 复制链接分享
  • dongqu4443 dongqu4443 9年前

    According to the documentation now, you can do this as part of the instantiation...

    $redis = new Predis\Client(array(
        'host'     => '', 
        'password' => 'secret', 
        'database' => 10, 


    $redis = new Predis\Client('redis://');
    点赞 评论 复制链接分享
  • doudang9147 doudang9147 8年前
    $db = 1;
    $aRedisServers['port']= "6379";
    $r = new Predis_Client();
    $r->connect($aRedisServers['host'], $aRedisServers['port']);
    echo $r->get("set");
    //output new
    点赞 评论 复制链接分享