public function ChainedStorage::setIfNotExists in Supercache 2.0.x
Same name and namespace in other branches
- 8 src/KeyValueStore/ChainedStorage.php \Drupal\supercache\KeyValueStore\ChainedStorage::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.
Overrides DatabaseStorage::setIfNotExists
File
- src/
KeyValueStore/ ChainedStorage.php, line 120 - Contains \Drupal\supercache\KeyValueStore\ChainedStorage;
Class
- ChainedStorage
- Defines a chained key value storage that uses any cache backend on top of the database default key/value storage.
Namespace
Drupal\supercache\KeyValueStoreCode
public function setIfNotExists($key, $value) {
$result = parent::setIfNotExists($key, $value);
if ($result == Merge::STATUS_INSERT) {
$this->cache
->set($key, $value);
}
return $result;
}