remember( $this->cacheKeyBuilder->buildCacheKeyFromArgs('post-page', $page, $filters, $orderDef), $this->cacheTtl, function () use ($page, $filters, $orderDef) { return parent::fetchPosts($page, $filters, $orderDef); } ); } public function findPost(int $id): ?Post { return Cache::tags(['posts', 'find-post-' . $id]) ->remember('post-' . $id, $this->cacheTtl, function () use ($id) { return parent::findPost($id); }); } public function storePost(array $data): Post { $newPost = parent::storePost($data); Cache::tags('fetch-posts')->flush(); return $newPost; } public function updatePost(array $data, int $id): ?Post { $updatedPost = parent::updatePost($data, $id); if ($updatedPost !== null) { Cache::tags('fetch-posts')->flush(); Cache::tags('find-post-' . $id)->flush(); } return $updatedPost; } public function deletePost(int $id): bool { Cache::tags('fetch-posts')->flush(); Cache::tags('find-post-' . $id)->flush(); return parent::deletePost($id); // TODO: Change the autogenerated stub } }