8000 Make RetryTillSaveStore implements the SharedLockStoreInterface by jderusse · Pull Request #38193 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Make RetryTillSaveStore implements the SharedLockStoreInterface #38193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make RetryTillSaveStore implements the SharedLockStoreInterface
  • Loading branch information
jderusse committed Sep 16, 2020
commit a0321e66c9187535b3fa3df62c157030f47d8145
22 changes: 21 additions & 1 deletion src/Symfony/Component/Lock/Store/RetryTillSaveStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
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
* blocking storage.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface
class RetryTillSaveStore implements BlockingStoreInterface, SharedLockStoreInterface, LoggerAwareInterface
{
use LoggerAwareTrait;

Expand Down Expand Up @@ -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}
*/
Expand Down
0