Skip to content

Commit 60085be

Browse files
authored
Merge pull request #3 from mSprunskas/master
Fixed failure of lock acquirement during concurrent requests
2 parents 89e520a + fe550c6 commit 60085be

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 1.0.0
8+
### Changed
9+
- `\Paysera\Bundle\LockBundle\Service\LockManager::createLock` now creates lock without TTL
10+
- Added strict type declaration in `\Paysera\Bundle\LockBundle\Service\LockManager`
11+
- Updated README.md
12+
713
## 0.2.1
814
### Changed
915
- `PayseraLockExtension` Definition method **setArgument** is replaced to **replaceArgument** so bundle will work properly on Symfony ^2.8

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@
33
Provides quick integration with `symfony/lock`
44

55
### Installation
6+
- Install package
67
```bash
78
composer require paysera/lib-lock-bundle
89
```
10+
- Enable bundle
11+
```php
12+
class AppKernel extends Kernel
13+
{
14+
public function registerBundles()
15+
{
16+
$bundles = [
17+
// ...
18+
new Paysera\Bundle\LockBundle\PayseraLockBundle(),
19+
];
20+
21+
// ...
22+
}
23+
}
24+
```
925

1026
### Configuration
1127
```yaml
@@ -30,13 +46,13 @@ paysera_lock:
3046
$lock = $this->lockManager->createLock($identifier);
3147
try {
3248
$this->lockManager->acquire($lock);
49+
50+
// do something after aquiring lock
3351
} catch (LockAcquiringException $exception) {
3452
throw new Exception('...');
53+
} finally {
54+
$lock->release();
3555
}
36-
37-
// do something when got lock
38-
39-
$lock->release();
4056
```
4157
OR
4258
```php
@@ -47,5 +63,4 @@ try {
4763
}
4864
4965
// do rest
50-
5166
```

src/Service/LockManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_type=1);
4+
35
namespace Paysera\Bundle\LockBundle\Service;
46

57
use Symfony\Component\Lock\Exception\LockAcquiringException;
@@ -21,7 +23,7 @@ public function __construct(
2123

2224
public function createLock(string $resource): LockInterface
2325
{
24-
return $this->lockFactory->createLock($resource, $this->ttl);
26+
return $this->lockFactory->createLock($resource, null);
2527
}
2628

2729
public function acquire(LockInterface $lock): bool

0 commit comments

Comments
 (0)