Skip to content

Commit 128bbd1

Browse files
committed
feature #38193 Make RetryTillSaveStore implements the SharedLockStoreInterface (jderusse)
This PR was merged into the 5.2-dev branch. Discussion ---------- Make RetryTillSaveStore implements the SharedLockStoreInterface | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | / | License | MIT | Doc PR | / The `RetryTillSaveStore` decorates a non blocking store (ie. `RedisStore`) to make it blockable. The issue is: if the decorate store manage SharedLock, the Decorator does not implements this interface. It's currently not possible to get both `blocking` and `sharable` store. Commits ------- a0321e6 Make RetryTillSaveStore implements the SharedLockStoreInterface
2 parents c34865f + a0321e6 commit 128bbd1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Symfony/Component/Lock/Store/RetryTillSaveStore.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
use Psr\Log\NullLogger;
1717
use Symfony\Component\Lock\BlockingStoreInterface;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
19+
use Symfony\Component\Lock\Exception\NotSupportedException;
1920
use Symfony\Component\Lock\Key;
2021
use Symfony\Component\Lock\PersistingStoreInterface;
22+
use Symfony\Component\Lock\SharedLockStoreInterface;
2123

2224
/**
2325
* RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a
2426
* blocking storage.
2527
*
2628
* @author Jérémy Derussé <jeremy@derusse.com>
2729
*/
28-
class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface
30+
class RetryTillSaveStore implements BlockingStoreInterface, SharedLockStoreInterface, LoggerAwareInterface
2931
{
3032
use LoggerAwareTrait;
3133

@@ -76,6 +78,24 @@ public function waitAndSave(Key $key)
7678
throw new LockConflictedException();
7779
}
7880

81+
public function saveRead(Key $key)
82+
{
83+
if (!$this->decorated instanceof SharedLockStoreInterface) {
84+
throw new NotSupportedException(sprintf('The "%s" store must decorate a "%s" store.', get_debug_type($this), ShareLockStoreInterface::class));
85+
}
86+
87+
$this->decorated->saveRead($key);
88+
}
89+
90+
public function waitAndSaveRead(Key $key)
91+
{
92+
if (!$this->decorated instanceof SharedLockStoreInterface) {
93+
throw new NotSupportedException(sprintf('The "%s" store must decorate a "%s" store.', get_debug_type($this), ShareLockStoreInterface::class));
94+
}
95+
96+
$this->decorated->waitAndSaveRead($key);
97+
}
98+
7999
/**
80100
* {@inheritdoc}
81101
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy