tagGenerator = $tagGenerator; } public function get(MediaPath $path, string $size, ?string $sizes): string { return Cache::tags($this->pathTag($path, $size))->rememberForever( $this->cacheKey($path, $size), fn () => $this->tagGenerator->generate($path, $size, $sizes) ); } public function delete(MediaPath $path): void { Cache::tags([$this->singlePathTag($path)])->flush(); } public function flush(): void { Cache::tags([$this->tagAll])->flush(); } private function cacheKey(MediaPath $path, string $size): string { return "resizer.{$size}.{$path->normal()}"; } private function pathTag(MediaPath $path, string $size): array { return [$this->tagAll, $this->singlePathTag($path)]; } public function singlePathTag(MediaPath $path): string { return "resizer.{$path->normal()}"; } }