From a0321e66c9187535b3fa3df62c157030f47d8145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 15 Sep 2020 11:39:42 +0200 Subject: [PATCH] Make RetryTillSaveStore implements the SharedLockStoreInterface --- .../Lock/Store/RetryTillSaveStore.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index c73ac06f3c1e4..59b09f0b55ce4 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -16,8 +16,10 @@ use Psr\Log\NullLogger; use Symfony\Component\Lock\BlockingStoreInterface; use Symfony\Component\Lock\Exception\LockConflictedException; +use Symfony\Component\Lock\Exception\NotSupportedException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\PersistingStoreInterface; +use Symfony\Component\Lock\SharedLockStoreInterface; /** * RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a @@ -25,7 +27,7 @@ * * @author Jérémy Derussé */ -class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface +class RetryTillSaveStore implements BlockingStoreInterface, SharedLockStoreInterface, LoggerAwareInterface { use LoggerAwareTrait; @@ -76,6 +78,24 @@ public function waitAndSave(Key $key) throw new LockConflictedException(); } + public function saveRead(Key $key) + { + if (!$this->decorated instanceof SharedLockStoreInterface) { + throw new NotSupportedException(sprintf('The "%s" store must decorate a "%s" store.', get_debug_type($this), ShareLockStoreInterface::class)); + } + + $this->decorated->saveRead($key); + } + + public function waitAndSaveRead(Key $key) + { + if (!$this->decorated instanceof SharedLockStoreInterface) { + throw new NotSupportedException(sprintf('The "%s" store must decorate a "%s" store.', get_debug_type($this), ShareLockStoreInterface::class)); + } + + $this->decorated->waitAndSaveRead($key); + } + /** * {@inheritdoc} */