Clear single result cache in symfony2 with APCu

236 views Asked by At

let's say that I have simple action

/**
 * @Route("/{record}", name="record_view")
 * @ParamConverter("record", class="AcmeDemoBundle:Record", options={"id" : "record"})
 * @param Request $request
 * @param Record $record
 * @return Response
 */
public function recordViewAction(Request $request, Record $record)
{
    return new Response($record->getContent());
}

and in other action which I update record content (not with forms)

/**
 * @Route("/edit/{record}", name="record_edit")
 * @ParamConverter("record", class="AcmeDemoBundle:Record", options={"id" : "record"})
 * @param Request $request
 * @param Record $record
 * @return Response
 */
public function recordEditAction(Request $request, Record $record)
{
    $orm = $this->getDoctrine()->getManager();

    $record->setContent('lorem ipsum');

    $orm->persist($record);
    $orm->flush();
}

Problem is when edit function is called, the view action have old content.. I'm using APCu so my config looks like this:

doctrine:
    orm:
        metadata_cache_driver: apcu
        result_cache_driver: apcu
        query_cache_driver: apcu

I know I can delete specific/all cache, but on specific cache, basing on paramConverter annotation, I don't have result cache id? Is there any solution to delete specific result? Maybe in flush listener?

0

There are 0 answers