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

Breadcrumb

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

function Lock::refresh

Overrides LockInterface::refresh

2 calls to Lock::refresh()
Lock::acquire in vendor/symfony/lock/Lock.php
Acquires the lock. If the lock is acquired by someone else, the parameter `blocking` determines whether or not the call should block until the release of the lock.
Lock::acquireRead in vendor/symfony/lock/Lock.php
Acquires the lock for reading. If the lock is acquired by someone else in write mode, the parameter `blocking` determines whether or not the call should block until the release of the lock.

File

vendor/symfony/lock/Lock.php, line 178

Class

Lock
Lock is the default implementation of the LockInterface.

Namespace

Symfony\Component\Lock

Code

public function refresh(?float $ttl = null) : void {
    if (!($ttl ??= $this->ttl)) {
        throw new InvalidArgumentException('You have to define an expiration duration.');
    }
    try {
        $this->key
            ->resetLifetime();
        $this->store
            ->putOffExpiration($this->key, $ttl);
        $this->dirty = true;
        if ($this->key
            ->isExpired()) {
            try {
                $this->release();
            } catch (\Exception) {
                // swallow exception to not hide the original issue
            }
            throw new LockExpiredException(\sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
        }
        $this->logger?->debug('Expiration defined for "{resource}" lock for "{ttl}" seconds.', [
            'resource' => $this->key,
            'ttl' => $ttl,
        ]);
    } catch (LockConflictedException $e) {
        $this->dirty = false;
        $this->logger?->notice('Failed to define an expiration for the "{resource}" lock, someone else acquired the lock.', [
            'resource' => $this->key,
        ]);
        throw $e;
    } catch (\Exception $e) {
        $this->logger?->notice('Failed to define an expiration for the "{resource}" lock.', [
            'resource' => $this->key,
            'exception' => $e,
        ]);
        throw new LockAcquiringException(\sprintf('Failed to define an expiration for the "%s" lock.', $this->key), 0, $e);
    }
}

API Navigation

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