Skip to content

Commit 18cbd38

Browse files
Fixes #46
1 parent d94ca2c commit 18cbd38

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Proxy.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Support\Str;
1212

1313
use function app;
14+
use function array_filter;
1415
use function array_shift;
1516
use function is_array;
1617
use function max;
@@ -159,7 +160,11 @@ protected function retrieveResultsFromCache(string $key): array
159160
return [$key => null, $this->cache->key => null];
160161
}
161162

162-
return $this->repository->getMultiple([$key, $this->cache->key]);
163+
$result = $this->repository->getMultiple(array_filter([$key, $this->cache->key]));
164+
165+
$result[$this->cache->key] ??= null;
166+
167+
return $result;
163168
}
164169

165170
/**

tests/ProxyTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function test_uses_custom_time_to_live(): void
370370
$interval = $now->diffAsCarbonInterval(now());
371371

372372
$repository = $this->mock(Repository::class);
373-
$repository->expects('getMultiple')->with([$hash, ''])->times(4)->andReturn(['' => null, $hash => null]);
373+
$repository->expects('getMultiple')->with([$hash])->times(4)->andReturn(['' => null, $hash => null]);
374374
$repository->allows('getStore')->never();
375375
$repository->expects('put')->with($hash, Mockery::type('array'), null);
376376
$repository->expects('put')->with($hash, Mockery::type('array'), $seconds);
@@ -560,7 +560,7 @@ public function test_uses_custom_store(): void
560560
$repository = $this->mock(Repository::class);
561561
$repository->expects('flexible')->never();
562562
$repository->expects('put')->with($hash, Mockery::type('array'), 60)->once();
563-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
563+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
564564

565565
$this->mock('cache')->expects('store')->with('test-store')->andReturn($repository);
566566

@@ -630,7 +630,7 @@ public function test_doesnt_uses_flexible_caching_if_repository_is_not_flexible(
630630
$repository = $this->mock(Repository::class);
631631
$repository->expects('flexible')->never();
632632
$repository->expects('put')->with($hash, Mockery::type('array'), [5, 300])->once();
633-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
633+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
634634

635635
$this->mock('cache')->expects('store')->with(null)->andReturn($repository);
636636

@@ -921,7 +921,7 @@ public function test_base_query_uses_cache_callback(): void
921921
$repository = $this->mock(Repository::class);
922922
$repository->expects('flexible')->never();
923923
$repository->expects('put')->with($hash, Mockery::type('array'), [5, 300])->once();
924-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
924+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
925925

926926
$this->mock('cache')->expects('store')->with(null)->andReturn($repository);
927927

0 commit comments

Comments
 (0)