Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DoctrineDbalStore.php

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\Store

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal