Connecting to Redis To Go with PHP(连接到 Redis 以使用 PHP)
问题描述
我是 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:连接到 Redis 以使用 PHP


基础教程推荐
- 将变量从树枝传递给 js 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- php中的PDF导出 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01