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