can predis use array as 2nd parameter of hmget() to retrieve multiple fields on one go? e.g. $client->hmget($key, $fields); //$fields is an array
Can it also accept many parameters of string as fields? e.g.: $client->hmget($key, $field1, $field2, $field3);
Predis supports two ways of passing multiple keys (or keys with values) for variadic Redis commands. The first one basically follows the same signature of commands as defined by the Redis documentation, so using HMSET and HMGET as examples you will have:
$redis->hmset("hash", "field:1", "value:1", "field:2", "value:2");
$values = $redis->hmget("hash", "field:1", "field:2");
but you can also pass the list of keys and/or values as a single array argument:
$redis->hmset("hash", array("field:1" => "value:1", "field:2" => "value:2"));
$values = $redis->hmget("hash", array("field:1", "field:2"));
Choosing which one to use is really just a matter of preference.
From Predis repository
$redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut');
$redis->hmget('metavars', 'foo', 'hoge', 'unknown'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With