You are here

protected function Redis_Path_Predis::deleteInHash in Redis 7.3

Same name and namespace in other branches
  1. 7.2 lib/Redis/Path/Predis.php \Redis_Path_Predis::deleteInHash()

@todo document me

Parameters

string $key:

string $hkey:

string $hvalue:

Overrides Redis_Path_AbstractHashLookup::deleteInHash

File

lib/Redis/Path/Predis.php, line 44

Class

Redis_Path_Predis
PhpRedis implementation.

Code

protected function deleteInHash($key, $hkey, $hvalue) {
  $client = $this
    ->getClient();
  $value = $client
    ->hget($key, $hkey);
  if ($value) {
    $existing = explode(self::VALUE_SEPARATOR, $value);
    if (false !== ($index = array_search($hvalue, $existing))) {
      if (1 === count($existing)) {
        $client
          ->hdel($key, $hkey);
      }
      else {
        unset($existing[$index]);
        $client
          ->hset($key, $hkey, implode(self::VALUE_SEPARATOR, $existing));
      }
    }
  }
}