如何知道条令2+zend framewrok中的缓存是否工作


How to know if the cache in doctrine 2 + zend framewrok is working?

以下是我在条令2+zend framewrok 2项目中对缓存的配置: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'
                ),
            )
        ),
        'configuration' => array(
            'orm_default' => array(
                'metadata_cache'    => 'mycache',
                'query_cache'       => 'mycache',
                'result_cache'      => 'mycache',
            )
        )
    ),
    'service_manager' => array(
        'factories' => array(
            'translator' => 'Zend'I18n'Translator'TranslatorServiceFactory',
            'navigation' => 'Zend'Navigation'Service'DefaultNavigationFactory', 
        // fin  la partie ajouté pour le cache doctrine 2 
             'doctrine.cache.mycache' => function ($sm) {
            $cache = new 'Doctrine'Common'Cache'MemcacheCache();
            $memcache = new 'Memcache();
            $memcache->connect('localhost', 11211);
            $cache->setMemcache($memcache);
            return $cache;
        },
        ),
    ),

我没有错误,但我需要知道缓存是否工作?如何做到这一点?谢谢

如果您需要检查ZF和Doctrine Cache之间的集成,您可以更改缓存配置以使用文件系统适配器并检查data文件夹中的文件:

'configuration' => array(
    'orm_default' => array(
        'metadata_cache'    => 'filesystem',
        'query_cache'       => 'filesystem',
        'result_cache'      => 'filesystem',
    )
)

如果您需要检查数据是否写入memcache,您可以使用telnet API:

连接:

telnet 127.0.0.1 11211

列出所有项目:

stats items