I am trying to add caching to an existing Symfony project. But I am unsure how best to proceed I get an array with ids. I check every id if there is an item in the cache. If not, then break and send a query to the database. Then I'll get the result and now I can store these values in my cache. But I have no idea how to set the id as a key
public function getHelpfulResult(array $reviewIds): array
{
    
    $helpfulCache = new FilesystemAdapter("helpful", 2 * 60 * 60, "cache");
    $helpfulValues = [];
    foreach ($reviewIds[0] as $id) {
        $item = $helpfulCache->getItem((string)$id);
        if($item->isHit()) {
            array_push($helpfulValues, $item);
        } else {
            break;
        }
    }
    $repo = $this->getDoctrine()->getRepository('Project:Test\Helpful', 'reviews');
    $query = $repo->createQueryBuilder('helpful')
        ->where("helpful.parentId IN (:parentIds) AND helpful.type = 'review'")
        ->setParameter('parentIds', $reviewIds)
        ->getQuery();
    $result = $query->getResult();
    foreach($result as $item) {
        $cache->set($item);
    }
    $cache->save();
    return $result;
}
 
    