|
16 | 16 | use Psr\Log\NullLogger;
|
17 | 17 | use Symfony\Component\Lock\BlockingStoreInterface;
|
18 | 18 | use Symfony\Component\Lock\Exception\LockConflictedException;
|
| 19 | +use Symfony\Component\Lock\Exception\NotSupportedException; |
19 | 20 | use Symfony\Component\Lock\Key;
|
20 | 21 | use Symfony\Component\Lock\PersistingStoreInterface;
|
| 22 | +use Symfony\Component\Lock\SharedLockStoreInterface; |
21 | 23 |
|
22 | 24 | /**
|
23 | 25 | * RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a
|
24 | 26 | * blocking storage.
|
25 | 27 | *
|
26 | 28 | * @author Jérémy Derussé <jeremy@derusse.com>
|
27 | 29 | */
|
28 |
| -class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface |
| 30 | +class RetryTillSaveStore implements BlockingStoreInterface, SharedLockStoreInterface, LoggerAwareInterface |
29 | 31 | {
|
30 | 32 | use LoggerAwareTrait;
|
31 | 33 |
|
@@ -76,6 +78,24 @@ public function waitAndSave(Key $key)
|
76 | 78 | throw new LockConflictedException();
|
77 | 79 | }
|
78 | 80 |
|
| 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 | + |
79 | 99 | /**
|
80 | 100 | * {@inheritdoc}
|
81 | 101 | */
|
|
0 commit comments