问题描述
我对Redis的一个新手...我刚刚拿起与在Redis的工作PHP ...和我有吨的乐趣!不过,我注册了服务,并已打我的头连接到使用服务..
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...
的URI字符串如下:
Redis的:// [用户名]:[通] @ [服务器] .redistogo.com:[港口] /
该Redisent客户只需在需要的主机名和端口...而且也没有地方让我输入用户名/密码...: - /我一直在用的fsockopen()函数摆弄周围,太。 ..但没有得分。
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.
有没有人尝试连接到Redis的去用PHP?如果是这样,任何见解或指针会大大AP preciated!
Has anyone tried connecting to Redis to go with PHP? If so, any insights or pointers would be greatly appreciated!
注:我知道有一个REST API可用的,但是这是用于配置实例,而不是实际的操作,如GET / SET等
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.
推荐答案
)来使用。
predis is the prefered library(active development => 6 Januari 2011) to use.
redis://$x:$y@$z
然后,你需要以下code得到它的工作(我测试):
Then you need the following code to get it working(I tested it):
<?php
require('./Predis.php');
#redis://$x:$y@$z
$redis = new Predis\Client('redis://$z');
$redis->auth($y);
$redis->incr('counter');
echo $redis->get('counter');
echo "\n";
但奇怪的是 $ X
。这是没有必要的?
这篇关于连接到Redis的使用PHP去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!