Monday, 15 August 2011

php - How to store queries and their results in memcache using cache enabled for doctrine 2 (using zend framework 2 )? -



php - How to store queries and their results in memcache using cache enabled for doctrine 2 (using zend framework 2 )? -

i guess in title , i've looked lot solution can't figure out how ? here configuration memcache in module.config.php :

// doctrine config 'doctrine' => array( 'driver' => array( __namespace__ . '_driver' => array( 'class' => 'doctrine\orm\mapping\driver\annotationdriver', 'paths' => array(__dir__ . '/../src/' . __namespace__ . '/entity') ), 'orm_default' => array( 'drivers' => array( __namespace__ . '\entity' => __namespace__ . '_driver' ), ) ), /***** enabling memcache ****/ 'configuration' => array( 'orm_default' => array( 'metadata_cache' => 'mycache', 'query_cache' => 'mycache', 'result_cache' => 'mycache', ) /**** end ****/ ) ), 'service_manager' => array( 'factories' => array( 'translator' => 'zend\i18n\translator\translatorservicefactory', 'navigation' => 'zend\navigation\service\defaultnavigationfactory', 'doctrine.cache.mycache' => function ($sm) { $cache = new \doctrine\common\cache\memcachecache(); $memcache = new \memcache(); $memcache->connect('localhost', 11211); $cache->setmemcache($memcache); homecoming $cache; }, ), ),

i'm using zend framework 2 , doctrine 2 . thanks.

if configured correctly don't need configure else query cache , metadata cache work, however, enable result cache have phone call useresultcache explicitly on each query.

example:

<?php $query = $em->createquery('select u \entities\user u'); $query->useresultcache(true);

php caching doctrine2 zend-framework2 doctrine

No comments:

Post a Comment