function DoctrineDbalStore::save
Overrides PersistingStoreInterface::save
File
-
vendor/
symfony/ lock/ Store/ DoctrineDbalStore.php, line 93
Class
- DoctrineDbalStore
- DbalStore is a PersistingStoreInterface implementation using a Doctrine DBAL connection.
Namespace
Symfony\Component\Lock\StoreCode
public function save(Key $key) : void {
$key->reduceLifetime($this->initialTtl);
$sql = "INSERT INTO {$this->table} ({$this->idCol}, {$this->tokenCol}, {$this->expirationCol}) VALUES (?, ?, {$this->getCurrentTimestampStatement()} + {$this->initialTtl})";
try {
$this->conn
->executeStatement($sql, [
$this->getHashedKey($key),
$this->getUniqueToken($key),
], [
ParameterType::STRING,
ParameterType::STRING,
]);
} catch (TableNotFoundException) {
if (!$this->conn
->isTransactionActive() || $this->platformSupportsTableCreationInTransaction()) {
$this->createTable();
}
try {
$this->conn
->executeStatement($sql, [
$this->getHashedKey($key),
$this->getUniqueToken($key),
], [
ParameterType::STRING,
ParameterType::STRING,
]);
} catch (DBALException) {
$this->putOffExpiration($key, $this->initialTtl);
}
} catch (DBALException) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
}
$this->randomlyPrune();
$this->checkNotExpired($key);
}