我是 Redis 的新手...我最近才开始学习 Redisent 来使用 RedisPHP...而且我玩得很开心!但是,我注册了 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...
URI 字符串如下:
redis://[用户名]:[pass]@[server].redistogo.com:[端口]/
redis://[username]:[pass]@[server].redistogo.com:[port]/
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?如果是这样,任何见解或指示将不胜感激!
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 是首选库(积极开发 => 2011 年 1 月 6 日) 使用.
predis is the prefered library(active development => 6 Januari 2011) to use.
redis://$x:$y@$z
然后你需要下面的代码来让它工作(我测试过):
Then you need the following code to get it working(I tested it):
<?php
require('./Predis.php');
#redis://$x:$y@$z
$redis = new PredisClient('redis://$z');
$redis->auth($y);
$redis->incr('counter');
echo $redis->get('counter');
echo "
";
奇怪的是$x
.根本不需要?
The strange thing is $x
. It is not needed at all?
这篇关于连接到 Redis 以使用 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!