zadd support multiple scores & values via redis.io: ZADD key score member [score] [member]
but i tried : $redis->zadd($key, array(1,2,3), array('a', 'b', 'c')), and it doesn't work, the result as
Array
(
[Array] => 1
)
and i also tried :
$params = array($k);
$s = (array)$s;
$m = (array)$m;
foreach ($s as $n => $i)
{
$params[] = $i;
$params[] = $m[$n];
}
return call_user_func_array(array('parent', 'zAdd'), $params);
and it doesn't work too
so if phpredis support this feature, could u pls show me how to use it
thx
hi @RobChen,
Redis::zAdd accepts following signature when you passing multiple elements.
for example:
<?php
r = new Redis();
$r->connect("localhost");
$key = "zadd_test";
$scores = array(1,2,3,4);
$values = array('a','b','c','d');
$args = array();
$length = count($scores);
$args[] = $key;
for ($i = 0; $i < $length; $i++) {
$args[] = $scores[$i];
$args[] = $values[$i];
}
call_user_func_array(array($r,'zAdd'),$args);
you know redis-server must be 2.4 higher when you want to set multiple scores.
Thanks @chobie!
Thanks @chobie
i found my phpredis version is 2 low to cause that problem
thx
@chobie good!
Most helpful comment
hi @RobChen,
Redis::zAdd accepts following signature when you passing multiple elements.
Redis::zAdd(key, score, value[, score, value...])
for example:
you know redis-server must be 2.4 higher when you want to set multiple scores.