8000 [Lock] Consolidate enforcement of Lock expiry · Issue #28779 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Lock] Consolidate enforcement of Lock expiry #28779
Closed
@kralos

Description

@kralos

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0