Skip to content

Commit 273153b

Browse files
authored
Merge pull request #165 from xav-developer/fix/lock
Fix: lock
2 parents f7b7c23 + 8e07bdd commit 273153b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
2121
- Fixed the `$ttl` in the `increment` method
2222
- The `forever` method passed `$seconds` as 0, `Spiral\RoadRunner\KeyValue` summed `timestamp + 0`, and `forever` was not `forever`
2323
- When using `prefix`, the `many` method returns values with `prefix`
24+
- The `Spiral\RoadRunner\KeyValue\Cache` class will set the value regardless of whether it exists or not - it always resolves the lock, you need to check for the existence of the key using the `has` method
2425

2526
[#147]:https://github.com/roadrunner-php/laravel-bridge/issues/147
2627

src/Cache/RoadRunnerLock.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public function __construct(
2525
*/
2626
public function acquire()
2727
{
28+
if ($this->storage->has($this->name)) {
29+
return false;
30+
}
31+
2832
return $this->storage->set(
2933
$this->name,
3034
$this->owner,

0 commit comments

Comments
 (0)