Skip to content

Commit 77ef36b

Browse files
committed
Merge branch '5.x' into 6.x
2 parents ede1ae5 + c5c9189 commit 77ef36b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Stache/Duplicates.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ public function getItems()
7979

8080
public function find()
8181
{
82+
$lock = tap($this->stache->lock('stache-warming'))->acquire(true);
83+
8284
$this->stache->stores()->flatMap(function ($store) {
8385
return $store instanceof AggregateStore ? $store->discoverStores() : [$store];
8486
})->each(function ($store) {
8587
$store->clearCachedPaths();
8688
$store->paths();
8789
});
8890

91+
$lock->release();
92+
8993
return $this;
9094
}
9195

tests/Stache/DuplicatesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,13 @@ public function it_finds_all_the_duplicates()
192192
$store3 = $this->mock(AggregateStore::class);
193193
$store3->shouldReceive('discoverStores')->once()->andReturn([$childStore]);
194194

195+
$lock = $this->mock(\Symfony\Component\Lock\LockInterface::class);
196+
$lock->shouldReceive('acquire')->with(true)->once()->andReturnTrue();
197+
$lock->shouldReceive('release')->once();
198+
195199
$stache = $this->mock(Stache::class);
196200
$stache->shouldReceive('stores')->andReturn(collect([$store1, $store2, $store3]));
201+
$stache->shouldReceive('lock')->with('stache-warming')->once()->andReturn($lock);
197202

198203
$duplicates = (new Duplicates($stache));
199204

0 commit comments

Comments
 (0)