public function getMulti(array $keys, array &$tokens = null)
{
$this->client->multi();
$this->client->mget($keys);
foreach ($keys as $key) {
$this->client->exists($key);
}
/** @var array $return */
$return = $this->client->exec();
if ($return === false) {
return array();
}
$values = array_shift($return);
$exists = $return;
if ($values === false) {
$values = array_fill_keys($keys, false);
}
$values = array_combine($keys, $values);
$exists = array_combine($keys, $exists);
$tokens = array();
foreach ($values as $key => $value) {
// filter out non-existing values
if ($exists[$key] === false) {
unset($values[$key]);
continue;
}
// serializing to make sure we don't pass objects (by-reference) ;)
$tokens[$key] = serialize($value);
}
return $values;
}