Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #32198 [Lock] Split "StoreInterface" into multiple interfaces…
… with less responsability (Simperfit) This PR was squashed before being merged into the 4.4 branch (closes #32198). Discussion ---------- [Lock] Split "StoreInterface" into multiple interfaces with less responsability | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | Contribute to #28694 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | TODO <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> We are removing the StoreInterface in order to split into multiple interface, it will help reduce de responsability of the StoreInterface. Firstly, since not all stores needs to have all the methods of the StoreInterface, we can split this like this in order to limit the methods that are needed for each store. Secondly, we add supportsX methods in order to avoid throwing exception when a store does not supports a feature it's easier an instance of the special interface or not, and it can return true/false on the support method. **Really big thanks to** @jderusse for working with me on this, 1-2 hours of talking together, and another 1-2 hours of pre-review :). now giving it to the whole community ! *some time has been sponsored by* @izisolutions Commits ------- 91fcbea [Lock] Split \"StoreInterface\" into multiple interfaces with less responsability
- Loading branch information
Showing
16 changed files
with
291 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Lock; | ||
|
||
use Symfony\Component\Lock\Exception\LockConflictedException; | ||
use Symfony\Component\Lock\Exception\NotSupportedException; | ||
|
||
/** | ||
* @author Hamza Amrouche <hamza.simperfit@gmail.com> | ||
*/ | ||
interface BlockingStoreInterface | ||
{ | ||
/** | ||
* Waits until a key becomes free, then stores the resource. | ||
* | ||
* If the store does not support this feature it should throw a NotSupportedException. | ||
* | ||
* @throws LockConflictedException | ||
* @throws NotSupportedException | ||
*/ | ||
public function waitAndSave(Key $key); | ||
|
||
/** | ||
* Checks if the store can wait until a key becomes free before storing the resource. | ||
*/ | ||
public function supportsWaitAndSave(): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Lock; | ||
|
||
use Symfony\Component\Lock\Exception\LockAcquiringException; | ||
use Symfony\Component\Lock\Exception\LockConflictedException; | ||
use Symfony\Component\Lock\Exception\LockReleasingException; | ||
|
||
/** | ||
* @author Jérémy Derussé <jeremy@derusse.com> | ||
*/ | ||
interface PersistStoreInterface | ||
{ | ||
/** | ||
* Stores the resource if it's not locked by someone else. | ||
* | ||
* @throws LockAcquiringException | ||
* @throws LockConflictedException | ||
*/ | ||
public function save(Key $key); | ||
|
||
/** | ||
* Removes a resource from the storage. | ||
* | ||
* @throws LockReleasingException | ||
*/ | ||
public function delete(Key $key); | ||
|
||
/** | ||
* Returns whether or not the resource exists in the storage. | ||
* | ||
* @return bool | ||
*/ | ||
public function exists(Key $key); | ||
|
||
/** | ||
* Extends the TTL of a resource. | ||
* | ||
* @param float $ttl amount of seconds to keep the lock in the store | ||
* | ||
* @throws LockConflictedException | ||
*/ | ||
public function putOffExpiration(Key $key, $ttl); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.