You are here

public function Redis_Cache_Predis::getMultiple in Redis 7.3

Same name and namespace in other branches
  1. 7 lib/Redis/Cache/Predis.php \Redis_Cache_Predis::getMultiple()
  2. 7.2 lib/Redis/Cache/Predis.php \Redis_Cache_Predis::getMultiple()

File

lib/Redis/Cache/Predis.php, line 59

Class

Redis_Cache_Predis
Predis cache backend.

Code

public function getMultiple(array $idList) {
  $ret = array();
  $pipe = $this
    ->getClient()
    ->pipeline();
  foreach ($idList as $id) {
    $pipe
      ->hgetall($this
      ->getKey($id));
  }
  $replies = $pipe
    ->execute();
  foreach (array_values($idList) as $line => $id) {

    // HGETALL signature seems to differ depending on Predis versions.
    // This was found just after Predis update. Even though I'm not sure
    // this comes from Predis or just because we're misusing it.
    if (!empty($replies[$line]) && is_array($replies[$line])) {
      $ret[$id] = $replies[$line];
    }
  }
  return $ret;
}