-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Lock] Consolidate enforcement of Lock expiry #28779
Copy link
Copy link
Closed
Labels
Description
Description
Enforcement of Lock\Key expiry is handled both by all of the Lock\Store\* as well as Lock\Lock. In the interest of DRY and maintaining consistent behavior, we should move enforcement to exist in Lock\Lock only.
Example
diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php
index c9200af199..dd92024288 100644
--- a/src/Symfony/Component/Lock/Store/MemcachedStore.php
+++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php
@@ -63,10 +63,6 @@ class MemcachedStore implements StoreInterface
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
}
-
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
- }
}
public function waitAndSave(Key $key)
@@ -109,10 +105,6 @@ class MemcachedStore implements StoreInterface
if (!$this->memcached->cas($cas, (string) $key, $token, $ttl)) {
throw new LockConflictedException();
}
-
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
}
/**Please See Lock\Lock::acquire and Lock\Lock::refresh:
if ($this->key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
}if ($this->key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
}Reactions are currently unavailable