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

Breadcrumb

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

function MemcachedStore::delete

Overrides PersistingStoreInterface::delete

File

vendor/symfony/lock/Store/MemcachedStore.php, line 100

Class

MemcachedStore
MemcachedStore is a PersistingStoreInterface implementation using Memcached as store engine.

Namespace

Symfony\Component\Lock\Store

Code

public function delete(Key $key) : void {
    $token = $this->getUniqueToken($key);
    [
        $value,
        $cas,
    ] = $this->getValueAndCas($key);
    if ($value !== $token) {
        // we are not the owner of the lock. Nothing to do.
        return;
    }
    // To avoid concurrency in deletion, the trick is to extends the TTL then deleting the key
    if (!$this->memcached
        ->cas($cas, (string) $key, $token, 2)) {
        // Someone steal our lock. It does not belongs to us anymore. Nothing to do.
        return;
    }
    // Now, we are the owner of the lock for 2 more seconds, we can delete it.
    $this->memcached
        ->delete((string) $key);
}

API Navigation

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