With PHP 7.0.10 and PHP Redis 3.0.0 :
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$key = 'foobar';
$fields = ['foo', 'bar'];
foreach ($fields as &$f) {}
$data = $redis->hmget($key, $fields);
var_dump($data); // bool(false)
$redisCluster = new RedisCluster(null, [
'127.0.0.1:7001',
'127.0.0.1:7002',
'127.0.0.1:7003',
]);
$key = 'foobar';
$fields = ['foo', 'bar'];
foreach ($fields as &$f) {}
$data = $redisCluster->hmget($key, $fields);
var_dump($data); // bool(false)
Just remove the &, it works:
$key = 'foobar';
$fields = ['foo', 'bar'];
foreach ($fields as $f) {}
$data = $redis->hmget($key, $fields);
var_dump($data); /* array(2) {
["foo"]=>
string(4) "blue"
["bar"]=>
string(2) "42"
} */
$key = 'foobar';
$fields = ['foo', 'bar'];
foreach ($fields as $f) {}
$data = $redisCluster->hmget($key, $fields);
var_dump($data); /* array(2) {
["foo"]=>
string(4) "blue"
["bar"]=>
string(2) "42"
} */
Not reproducible with PHP 5.6.24 and PHP Redis 2.2.8.
With PHP 7.0.10 and PHP Redis 3.0.0 :
Just remove the
&, it works:Not reproducible with PHP 5.6.24 and PHP Redis 2.2.8.