Without using any libraries like predis, what is the best way to do a Redis call from PHP?
I currently use the
exec
command but was wondering if there was a better way.exec('redis-cli SET foo bar');
Secondly, how do you perform a transaction? I can do it like so from the command line...
$ redis-cli redis 127.0.0.1:6379> MULTI OK redis 127.0.0.1:6379> INCR FOO QUEUED redis 127.0.0.1:6379> INCR BAR QUEUED redis 127.0.0.1:6379> EXEC 1) (integer) 1 2) (integer) 1
However if I tried to do it like this, each individual command gets executed separately, not within the same transaction and I end up getting the error
(error) ERR EXEC without MULTI
exec('redis-cli MULTI'); exec('redis-cli INCR FOO'); exec('redis-cli INCR BAR'); exec('redis-cli EXEC');