Implements Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface::setWithExpireIfNotExists().
Overrides KeyValueStoreExpirableInterface::setWithExpireIfNotExists
function setWithExpireIfNotExists($key, $value, $expire) {
// We are already writing to the table, so perform garbage collection at
// the end of this request.
$this->needsGarbageCollection = TRUE;
$result = $this->connection
->merge($this->table)
->insertFields(array(
'collection' => $this->collection,
'name' => $key,
'value' => serialize($value),
'expire' => REQUEST_TIME + $expire,
))
->condition('collection', $this->collection)
->condition('name', $key)
->execute();
return $result == Merge::STATUS_INSERT;
}