Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Lock] Consolidate enforcement of Lock expiry #28779

Copy link
Copy link
Closed
@kralos

Description

@kralos
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.