Skip to content

Commit a0321e6

Browse files
committed
Make RetryTillSaveStore implements the SharedLockStoreInterface
1 parent f1f37a8 commit a0321e6

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

+21-1
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)