forked from https://github.com/symfony/symfony
e5ddd14b1d
This PR was squashed before being merged into the 3.4 branch (closes #22113).
Discussion
----------
[Lock] Include lock component in framework bundle
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | none
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/8066
## Usage
use the best available "out of box" store (semaphore if available, filesyste otherwise)
```yml
framework:
lock: ~
# lock: true
```
```php
$this->get('lock')->acquire();
$this->get('lock.factory')->createLock('my resource')->acquire();
```
use a specific store
```yml
framework:
lock: flock
# lock: semaphore
# lock: redis://localhost
# lock: "%env(MEMCACHED_DSN)%"
# lock: ["%env(REDIS_DSN_1)%", "%env(REDIS_DSN_2)%"]
```
```php
$this->get('lock')->acquire();
$this->get('lock.factory')->createLock('my resource')->acquire();
```
use a named lock
```yml
framework:
lock:
foo: flock
bar: redis://localhost
```
```php
$this->get('lock.foo')->acquire();
$this->get('lock.bar.factory')->createLock('my resource')->acquire();
```
factory usage
```xml
<service id="acme" class="AppBundle\Acme">
<argument type="service">
<service class="Symfony\Component\Lock\Lock">
<factory service="lock.foo.factory" method="createLock" />
<argument>my resource</argument>
<argument>30</argument> <!-- optional TTL -->
</service>
</argument>
</service>
```
* [x] Tests
Commits
-------
|
||
---|---|---|
.composer | ||
.github | ||
src/Symfony | ||
.editorconfig | ||
.gitignore | ||
.php_cs.dist | ||
.travis.yml | ||
appveyor.yml | ||
CHANGELOG-3.0.md | ||
CHANGELOG-3.1.md | ||
CHANGELOG-3.2.md | ||
CHANGELOG-3.3.md | ||
composer.json | ||
CONTRIBUTING.md | ||
CONTRIBUTORS.md | ||
LICENSE | ||
phpunit | ||
phpunit.xml.dist | ||
README.md | ||
UPGRADE-3.0.md | ||
UPGRADE-3.1.md | ||
UPGRADE-3.2.md | ||
UPGRADE-3.3.md | ||
UPGRADE-3.4.md | ||
UPGRADE-4.0.md |
Symfony is a PHP framework for web applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).
Installation
- Install Symfony with Composer or with our own installer (see requirements details).
- Symfony follows the semantic versioning strictly, publishes "Long Term Support" (LTS) versions and has a release process that is predictable and business-friendly.
Documentation
- Read the Getting Started guide if you are new to Symfony.
- Try the Symfony Demo application to learn Symfony in practice.
- Master Symfony with the Guides and Tutorials, the Components docs and the Best Practices reference.
Community
- Join the Symfony Community and meet other members at the Symfony events.
- Get Symfony support on Stack Overflow, Slack, IRC, etc.
- Follow us on GitHub, Twitter and Facebook.
Contributing
Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.
Security Issues
If you discover a security vulnerability within Symfony, please follow our disclosure procedure.
About Us
Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.