cachePrefix . "preview_card-{$hashedPreviewCardUrl}"; if (! ($found = cache($cacheName))) { $found = $this->where('url', $url) ->first(); cache() ->save($cacheName, $found, DECADE); } return $found; } public function getPostPreviewCard(string $postId): ?PreviewCard { $cacheName = config('Fediverse') ->cachePrefix . "post#{$postId}_preview_card"; if (! ($found = cache($cacheName))) { $tablesPrefix = config('Fediverse') ->tablesPrefix; $found = $this->join( $tablesPrefix . 'posts_preview_cards', $tablesPrefix . 'posts_preview_cards.preview_card_id = id', 'inner', ) ->where('post_id', service('uuid') ->fromString($postId) ->getBytes()) ->first(); cache() ->save($cacheName, $found, DECADE); } return $found; } public function deletePreviewCard(int $id, string $url): BaseResult | bool { $hashedPreviewCardUrl = md5($url); cache() ->delete(config('Fediverse') ->cachePrefix . "preview_card-{$hashedPreviewCardUrl}"); return $this->delete($id); } }