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

Breadcrumb

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

function DoctrineDbalPostgreSqlStore::saveRead

Overrides SharedLockStoreInterface::saveRead

File

vendor/symfony/lock/Store/DoctrineDbalPostgreSqlStore.php, line 106

Class

DoctrineDbalPostgreSqlStore
DoctrineDbalPostgreSqlStore is a PersistingStoreInterface implementation using PostgreSql advisory locks with a Doctrine DBAL Connection.

Namespace

Symfony\Component\Lock\Store

Code

public function saveRead(Key $key) : void {
    // prevent concurrency within the same connection
    $this->getInternalStore()
        ->saveRead($key);
    $lockAcquired = false;
    try {
        $sql = 'SELECT pg_try_advisory_lock_shared(:key)';
        $result = $this->conn
            ->executeQuery($sql, [
            'key' => $this->getHashedKey($key),
        ]);
        // Check if lock is acquired
        if (true === $result->fetchOne()) {
            $key->markUnserializable();
            // release lock in case of demotion
            $this->unlock($key);
            $lockAcquired = true;
            return;
        }
    } finally {
        if (!$lockAcquired) {
            $this->getInternalStore()
                ->delete($key);
        }
    }
    throw new LockConflictedException();
}

API Navigation

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