How do you run raw redis commands in PHP?

I used predis to try to figure out how to run raw redis commands, but I have problems. The documentation for predis is extremely outdated. It says that there is a method called "rawCommand ()" that will allow the user to run raw Redis commands, but I found a change log that says it is no longer supported: https://github.com/nrk/predis/ blame / master / CHANGELOG

Does anyone have any hints on how I can run raw redis commands?

+4
source share
3 answers

Here you go. This worked perfectly for me, and I didn’t even know that this function was

$cmdSet = $redis->createCommand('set'); $cmdSet->setArgumentsArray(array('library', 'predis')); $cmdSetReply = $redis->executeCommand($cmdSet); 

He has a wiki page. Find the send commands.

+2
source

I actually guess here, but let it pretend for a while, I did not say it out loud.

Check the writeCommand () function in lib / Predis / Network / StreamConnection.php on line 176 and use it through the SimpleDebuggableConnection in the /SimpleDebuggableConnection.php examples. You still need to define new commands that are not yet defined in lib / predis / commands, as indicated in the wiki referenced by @Colum.

If you really feel weird, change the protected writeBytes () method in StreamConnection on line 96 to public. This should allow you to feed him clean redis with

 $redis->getConnection()->writeBytes("*3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$7\r\nmyvalue\r\n") 

Unfortunately, the writeBytes () publication seems to go towards http://en.wikipedia.org/wiki/Object_orgy anti-pattern.

Good luck

0
source

It is easy!
Take this class: RedisServer
and write:

 $redis = new \Jamm\Memory\RedisServer(); $redis->send_command('set','key',5); //here any raw command 
0
source

All Articles