Memcache with Symfony / Doctrine - it reloads data

In my symfony project, I have a β€œcomplex” request that looks like this:

$d = Doctrine_Core::getTable('MAIN_TABLE')
    // Create the base query with some keywords
->luceneSearch($keywords)
->innerJoin('w.T1 ws')
->innerJoin('ws.T2 s')
    ->innerJoin('w.T3 piv')
->innerJoin('piv.T4 per')
->innerJoin('w.T5 st')
    ...
->innerJoin('doc.T12 docT')
->innerJoin('w.Lang lng')
->execute();

I added all these innerJoin to reduce the number of queries due to my data model. Virtually all data is recovered using this single request .... but the request took 2 to 20 seconds. depends on the keywords.

I decided to use memcache because the data does not change all the time.

What I did was configure memcache and add

...
->useResultCache(true)
->execute();

to my request.

It is strange that:

  • The first time (when the cache is empty / colored), only one request is executed
  • The second time ~ 130 ares is executed and takes longer than the first ...

These "new" queries retrieve data from the "inner join" for each record.

, " " ?

, , .

- ?

+3
1

googlise, , :

class User extends BaseUser{
    public function serializeReferences($bool=null)
    {
        return true;
    }
}

, , , , . , #doctrine, , , Doctrine . , , , serializeReferences, true , . User. " , true

http://shout.setfive.com/2010/04/28/using-doctrine-result-cache-with-two-deep-relations/

+1
source

Source: https://habr.com/ru/post/1795712/


All Articles