You are here

protected function Redis_Path_PhpRedis::deleteInHash in Redis 7.2

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

File

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

Class

Redis_Path_PhpRedis
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));
      }
    }
  }
}