Skip to content

Commit

Permalink
Update StatusHashtagService, remove problemaatic cache layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Nov 16, 2023
1 parent 33a60e7 commit e5401f8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions app/Services/StatusHashtagService.php
Expand Up @@ -84,18 +84,14 @@ public static function getStatus($statusId, $hashtagId)

public static function statusTags($statusId)
{
$key = 'pf:services:sh:id:' . $statusId;

return Cache::remember($key, 604800, function() use($statusId) {
$status = Status::find($statusId);
if(!$status) {
return [];
}
$status = Status::with('hashtags')->find($statusId);
if(!$status) {
return [];
}

$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Collection($status->hashtags, new HashtagTransformer());
return $fractal->createData($resource)->toArray();
});
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Collection($status->hashtags, new HashtagTransformer());
return $fractal->createData($resource)->toArray();
}
}

0 comments on commit e5401f8

Please sign in to comment.