Skip to content

Commit be5c52d

Browse files
authored
Refactor GetBrewery to remove caching logic (#101)
Co-authored-by: Alex Justesen <1144087+alexjustesen@users.noreply.github.com>
1 parent 2af7d93 commit be5c52d

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

app/Http/Controllers/Api/V1/GetBrewery.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Http\JsonResponse;
99
use Illuminate\Http\Request;
1010
use Illuminate\Http\Response;
11-
use Illuminate\Support\Facades\Cache;
1211

1312
class GetBrewery extends Controller
1413
{
@@ -17,9 +16,7 @@ class GetBrewery extends Controller
1716
*/
1817
public function __invoke(Request $request, string $id): JsonResponse
1918
{
20-
$brewery = Cache::remember('brewery_'.$id, config('platform.cache_control_max_age'), function () use ($id) {
21-
return new BreweryResource(Brewery::findOrFail($id));
22-
});
19+
$brewery = new BreweryResource(Brewery::findOrFail($id));
2320

2421
return response()
2522
->json(

tests/Feature/Api/V1/GetBreweryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
$response = $this->getJson("/v1/breweries/{$brewery->id}");
4040
$hasCache = Cache::has('brewery_'.$brewery->id);
4141
expect($hasCache)->toBeTrue();
42-
});
42+
})->skip(message: 'Caching was disabled for testing.');
4343

4444
test('response has correct json api structure', function () {
4545
$brewery = createBrewery();

0 commit comments

Comments
 (0)