连接到 Redis 以使用 PHP

Connecting to Redis To Go with PHP(连接到 Redis 以使用 PHP)
本文介绍了连接到 Redis 以使用 PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我是 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)