protected function Redis_Path_Predis::saveInHash in Redis 7.3
Same name and namespace in other branches
- 7.2 lib/Redis/Path/Predis.php \Redis_Path_Predis::saveInHash()
@todo document me
Parameters
string $key:
string $hkey:
string $hvalue:
Overrides Redis_Path_AbstractHashLookup::saveInHash
File
- lib/
Redis/ Path/ Predis.php, line 12
Class
- Redis_Path_Predis
- PhpRedis implementation.
Code
protected function saveInHash($key, $hkey, $hvalue) {
$client = $this
->getClient();
$value = $client
->hget($key, $hkey);
if ($value === self::VALUE_NULL) {
// Remove any null values
$value = null;
}
if ($value) {
$existing = explode(self::VALUE_SEPARATOR, $value);
if (!in_array($hvalue, $existing)) {
// Prepend the most recent path to ensure it always be
// first fetched one
// @todo Ensure in case of update that its position does
// not changes (pid ordering in Drupal core)
$value = $hvalue . self::VALUE_SEPARATOR . $value;
}
else {
// Do nothing on empty value
$value = null;
}
}
else {
if (empty($hvalue)) {
$value = self::VALUE_NULL;
}
else {
$value = $hvalue;
}
}
if (!empty($value)) {
$client
->hset($key, $hkey, $value);
}
// Empty value here means that we already got it
}