An example to use memcache for annotation caching would be (module.config.php):
'service_manager' => array(
'factories' => array(
'doctrine.cache.my_memcache' => function(\Zend\ServiceManager\ServiceManager $sm) {
$cache = new \Doctrine\Common\Cache\MemcacheCache();
$memcache = new \Memcache();
$memcache->connect('localhost', 11211);
$cache->setMemcache($memcache);
return $cache;
}
)
This creates the basic memcache object for doctrine. Afterwards, you have to tell doctrine to use this cache for annotations like this (again, module.config.php):
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'my_memcache', // <- this points to the doctrine.cache.my_memcache factory we created above
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
),
),
),
),
Alternatively, you can use the array cache of doctrine. simply change 'cache' => 'my_memcache' to 'cache' => 'array' (which should be the default anyway, as far as I know.
Hope that helps!