3

I got a problem similar to this one:

Connecting to Redis To Go with PHP

Basically, I have this uri in redis to go:

redis://myusername:[email protected]:9998

and I am trying to connect to it using phpredis:

$r->connect("redis://myusername:[email protected]:9998/");

And it's not working. In that other answer it is suggested to use predis, but I just don't want to. I should be free to use whatever client I want.

Any ideas?

Thanks in advance

1
  • +1 for standing against predis; phpredis is a native extension, it's bound to be more efficient than predis even if the development is less active. Commented Oct 23, 2012 at 22:17

3 Answers 3

4

Use this instead:

$r = new Redis();
$r->connect("herring.redistogo.com", 9998);
$r->auth("foopassword");

If that doesn't work, try $r->auth("myusername:foopassword") instead.

You can find the phpredis documentation on the official GitHub page.

Sign up to request clarification or add additional context in comments.

Comments

0

I have not used redistogo, but maybe you could try?

$r->connect('herring.redistogo.com', 9998);
$r->auth('myusername:foopassword');

Comments

0

I have figured out phpredis and learned some good things which I want to share them with you. See some examples from its GitHub repo. They implemented a mixed style where we can freely provide a password or username and password. In my snippet code, I use both username and password, therefore we need to leave them in an array.

<?php
global $redis;
$redis = new Redis();
// Connecting to Redis
$redis->connect("127.0.0.1", 6379);
$redis->auth(["admin", "yourpassword_is_given_here"]);

if ($redis->ping()) {
    echo "PONG";
}

?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.