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

Breadcrumb

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

function CombinedStore::putOffExpiration

Overrides PersistingStoreInterface::putOffExpiration

File

vendor/symfony/lock/Store/CombinedStore.php, line 121

Class

CombinedStore
CombinedStore is a PersistingStoreInterface implementation able to manage and synchronize several StoreInterfaces.

Namespace

Symfony\Component\Lock\Store

Code

public function putOffExpiration(Key $key, float $ttl) : void {
    $successCount = 0;
    $failureCount = 0;
    $storesCount = \count($this->stores);
    $expireAt = microtime(true) + $ttl;
    foreach ($this->stores as $store) {
        try {
            if (0.0 >= ($adjustedTtl = $expireAt - microtime(true))) {
                $this->logger?->debug('Stores took to long to put off the expiration of the "{resource}" lock.', [
                    'resource' => $key,
                    'store' => $store,
                    'ttl' => $ttl,
                ]);
                $key->reduceLifetime(0);
                break;
            }
            $store->putOffExpiration($key, $adjustedTtl);
            ++$successCount;
        } catch (\Exception $e) {
            $this->logger?->debug('One store failed to put off the expiration of the "{resource}" lock.', [
                'resource' => $key,
                'store' => $store,
                'exception' => $e,
            ]);
            ++$failureCount;
        }
        if (!$this->strategy
            ->canBeMet($failureCount, $storesCount)) {
            break;
        }
    }
    $this->checkNotExpired($key);
    if ($this->strategy
        ->isMet($successCount, $storesCount)) {
        return;
    }
    $this->logger?->notice('Failed to define the expiration for the "{resource}" lock. Quorum has not been met.', [
        'resource' => $key,
        'success' => $successCount,
        'failure' => $failureCount,
    ]);
    // clean up potential locks
    $this->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