function DoctrineDbalStore::putOffExpiration
Overrides PersistingStoreInterface::putOffExpiration
1 call to DoctrineDbalStore::putOffExpiration()
- DoctrineDbalStore::save in vendor/
symfony/ lock/ Store/ DoctrineDbalStore.php - Stores the resource if it's not locked by someone else.
File
-
vendor/
symfony/ lock/ Store/ DoctrineDbalStore.php, line 132
Class
- DoctrineDbalStore
- DbalStore is a PersistingStoreInterface implementation using a Doctrine DBAL connection.
Namespace
Symfony\Component\Lock\StoreCode
public function putOffExpiration(Key $key, $ttl) : void {
if ($ttl < 1) {
throw new InvalidTtlException(\sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
}
$key->reduceLifetime($ttl);
$sql = "UPDATE {$this->table} SET {$this->expirationCol} = {$this->getCurrentTimestampStatement()} + ?, {$this->tokenCol} = ? WHERE {$this->idCol} = ? AND ({$this->tokenCol} = ? OR {$this->expirationCol} <= {$this->getCurrentTimestampStatement()})";
$uniqueToken = $this->getUniqueToken($key);
$result = $this->conn
->executeQuery($sql, [
$ttl,
$uniqueToken,
$this->getHashedKey($key),
$uniqueToken,
], [
ParameterType::INTEGER,
ParameterType::STRING,
ParameterType::STRING,
ParameterType::STRING,
]);
// If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
if (!$result->rowCount() && !$this->exists($key)) {
throw new LockConflictedException();
}
$this->checkNotExpired($key);
}