function KeyValueStoreInterface::setIfNotExists
Same name in other branches
- 8.9.x core/lib/Drupal/Core/KeyValueStore/KeyValueStoreInterface.php \Drupal\Core\KeyValueStore\KeyValueStoreInterface::setIfNotExists()
- 10 core/lib/Drupal/Core/KeyValueStore/KeyValueStoreInterface.php \Drupal\Core\KeyValueStore\KeyValueStoreInterface::setIfNotExists()
- 11.x core/lib/Drupal/Core/KeyValueStore/KeyValueStoreInterface.php \Drupal\Core\KeyValueStore\KeyValueStoreInterface::setIfNotExists()
Saves a value for a given key if it does not exist yet.
Parameters
string $key: The key of the data to store.
mixed $value: The data to store.
Return value
bool TRUE if the data was set, FALSE if it already existed.
3 methods override KeyValueStoreInterface::setIfNotExists()
- DatabaseStorage::setIfNotExists in core/
lib/ Drupal/ Core/ KeyValueStore/ DatabaseStorage.php - Saves a value for a given key if it does not exist yet.
- MemoryStorage::setIfNotExists in core/
lib/ Drupal/ Core/ KeyValueStore/ MemoryStorage.php - Saves a value for a given key if it does not exist yet.
- NullStorageExpirable::setIfNotExists in core/
lib/ Drupal/ Core/ KeyValueStore/ NullStorageExpirable.php - Saves a value for a given key if it does not exist yet.
File
-
core/
lib/ Drupal/ Core/ KeyValueStore/ KeyValueStoreInterface.php, line 85
Class
- KeyValueStoreInterface
- Defines the interface for key/value store implementations.
Namespace
Drupal\Core\KeyValueStoreCode
public function setIfNotExists($key, $value);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.