function DatabaseStorageExpirable::setWithExpireIfNotExists

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::setWithExpireIfNotExists()
  2. 10 core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::setWithExpireIfNotExists()
  3. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::setWithExpireIfNotExists()

Overrides KeyValueStoreExpirableInterface::setWithExpireIfNotExists

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php, line 89

Class

DatabaseStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\Core\KeyValueStore

Code

public function setWithExpireIfNotExists($key, $value, $expire) {
    if (!$this->has($key)) {
        $this->setWithExpire($key, $value, $expire);
        return TRUE;
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.