-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use multi(Redis::PIPELINE) with RedisArray #251
Comments
Hey, You look to be calling it correctly from where I'm sitting. The only way (without stepping into phpredis code itself) to see if a pipeline is being used would be to compare the performance of using one and not using one. When you're using a pipeline you should see faster execution times. You can see if MULTI/EXEC is happening by monitoring Redis. This simple script allows you to either pass an argument or not (which will toggle Redis::PIPELINE or Redis::MULTI). When you do MULTI you can see it in your When you toggle to use if(isset($argv[1])) {
$mode = Redis::MULTI;
$m_str = 'MULTI';
} else {
$mode = Redis::PIPELINE;
$m_str = 'PIPELINE';
}
$st = microtime(true);
$r = new RedisArray(Array("localhost:6390", "localhost:6391"));
for($i=0;$i<100;$i++) {
$set = "set$i";
$host = $r->_target($set);
echo $host . "\n";
$pipe = $r->multi($host, $mode);
for($j=0;$j<100;$j++) {
$pipe->sadd($set, "value$j");
}
$pipe->exec();
}
$et = microtime(true);
echo "Timing ($m_str): " . ($et-$st) . "\n"; |
Confirm that I am using it correctly. Using michael-grunder's script, I have the following benchmarks: with Redis::MULTI 0.41849994659424 secs with Redis::PIPELINE 0.084672927856445 secs It would be great if the RedisArray readme file mentioned how to toggle the mode for multi() |
Basically using this in my code:
//$redis is a RedisArray here
$key = 'hello';
$host = $redis->_target($key);
$pipeline = $redis->multi($host, Redis::PIPELINE);
//put result in our shared list
foreach ($items as $item)
{
$pipeline->sAdd($key, $item);
}
$ret = $pipeline->exec();
The problem here is I have no clue if this is actually using PIPELINE or MULTI, and the documentation doesn't really specify how to use RedisArray multi with pipelining.
If anyone could confirm that I am using it correctly, I would really appreciate it.
Cheers
The text was updated successfully, but these errors were encountered: