Skip to content

Commit f0387d3

Browse files
committed
change lock collection signature
1 parent e1ae3f9 commit f0387d3

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/InMemoryLockCollection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ public function place(string $key, Lock $lock): Promise
4747
/**
4848
* @inheritDoc
4949
*/
50-
public function remove(string $key): Promise
50+
public function extract(string $key): Promise
5151
{
52+
$lock = InMemoryCollectionStorage::instance()->get($key);
53+
5254
InMemoryCollectionStorage::instance()->remove($key);
5355

54-
return new Success();
56+
return new Success($lock);
5557
}
5658
}

src/LockCollection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ public function has(string $key): Promise;
2323

2424
public function place(string $key, Lock $lock): Promise;
2525

26-
public function remove(string $key): Promise;
26+
/**
27+
* Returns \ServiceBus\Mutex\Lock|null
28+
*/
29+
public function extract(string $key): Promise;
2730
}

src/Storage/InMemoryCollectionStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function add(string $key, Lock $lock): void
5555
$this->localStorage[$key] = $lock;
5656
}
5757

58+
public function get(string $key): ?Lock
59+
{
60+
return $this->localStorage[$key] ?: null;
61+
}
62+
5863
/**
5964
* Reset instance.
6065
*/

0 commit comments

Comments
 (0)