function ChainedStorageExpirable::setWithExpireIfNotExists in Supercache 2.0.x
Same name and namespace in other branches
- 8 src/KeyValueStore/ChainedStorageExpirable.php \Drupal\supercache\KeyValueStore\ChainedStorageExpirable::setWithExpireIfNotExists()
Sets a value for a given key with a time to live if it does not yet exist.
If a key is expired it also does not exists.
Parameters
string $key: The key of the data to store.
mixed $value: The data to store.
int $expire: The time to live for items, in seconds.
Return value
bool TRUE if the data was set, or FALSE if it already existed.
Overrides DatabaseStorageExpirable::setWithExpireIfNotExists
File
- src/
KeyValueStore/ ChainedStorageExpirable.php, line 132 - Contains \Drupal\supercache\KeyValueStore\ChainedStorageExpirable.
Class
- ChainedStorageExpirable
- Defines a default key/value store implementation for expiring items.
Namespace
Drupal\supercache\KeyValueStoreCode
function setWithExpireIfNotExists($key, $value, $expire) {
$result = parent::setWithExpireIfNotExists($key, $value, $expire);
if ($result == Merge::STATUS_INSERT) {
$this->cache
->set($key, $value, REQUEST_TIME + $expire);
}
return $result;
}