You are here

protected function Redis_Path_PhpRedis::lookupInHash in Redis 7.3

Same name and namespace in other branches
  1. 7.2 lib/Redis/Path/PhpRedis.php \Redis_Path_PhpRedis::lookupInHash()

@todo document me

Parameters

string $keyPrefix:

string $hkey:

string $language:

Overrides Redis_Path_AbstractHashLookup::lookupInHash

File

lib/Redis/Path/PhpRedis.php, line 63

Class

Redis_Path_PhpRedis
PhpRedis implementation.

Code

protected function lookupInHash($keyPrefix, $hkey, $language = null) {
  $client = $this
    ->getClient();
  if (null === $language) {
    $language = LANGUAGE_NONE;
    $doNoneLookup = false;
  }
  else {
    if (LANGUAGE_NONE === $language) {
      $doNoneLookup = false;
    }
    else {
      $doNoneLookup = true;
    }
  }
  $ret = $client
    ->hget($this
    ->getKey(array(
    $keyPrefix,
    $language,
  )), $hkey);
  if ($doNoneLookup && (!$ret || self::VALUE_NULL === $ret)) {
    $previous = $ret;
    $ret = $client
      ->hget($this
      ->getKey(array(
      $keyPrefix,
      LANGUAGE_NONE,
    )), $hkey);
    if (!$ret || self::VALUE_NULL === $ret) {

      // Restore null placeholder else we loose conversion to false
      // and drupal_lookup_path() would attempt saving it once again
      $ret = $previous;
    }
  }
  if (self::VALUE_NULL === $ret) {
    return false;

    // Needs conversion
  }
  if (empty($ret)) {
    return null;

    // Value not found
  }
  $existing = explode(self::VALUE_SEPARATOR, $ret);
  return reset($existing);
}