You are here

protected function Redis_Path_Predis::deleteInHash in Redis 7.2

Same name and namespace in other branches
  1. 7.3 lib/Redis/Path/Predis.php \Redis_Path_Predis::deleteInHash()
1 call to Redis_Path_Predis::deleteInHash()
Redis_Path_Predis::deleteAlias in lib/Redis/Path/Predis.php
Alias is being deleted for the given source

File

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

Class

Redis_Path_Predis
PhpRedis implementation.

Code

protected function deleteInHash($key, $hkey, $hvalue) {
  $client = Redis_Client::getClient();
  $value = $client
    ->hget($key, $hkey);
  if ($value) {
    $existing = explode(self::VALUE_SEPARATOR, $value);
    if ($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));
      }
    }
  }
}