How to use ZendOpCache for Doctrine2 cache?

霸气de小男生 提交于 2019-11-30 03:55:39

问题


I have installed PHP 5.5.1 in my development environment, and also have config Zend OpCache as Cache provider. Everything is working on the server with the new version and settings, but inside my symfony 2 project I have the Doctine2 cache to store some "static" data (countries, languages, etc) and it not works with Opcache.

Until today, I was using the Doctrine\Common\Cache\ApcCache class to work with the cache of Doctrine2 using APC, but seems that does not exists a class to work with OpCache.

This is my config.yml for APC cache:

# Services
services:
    cache:
        class: Doctrine\Common\Cache\ApcCache

Now, with OpCache I have tried to use ZendDataCache to deal with cache system, but does not work:

# Services
services:
    cache:
        class: Doctrine\Common\Cache\ZendDataCache

I get this error, so I assume that ZendDataCache class is not for OpCache:

FatalErrorException: Error: Call to undefined function Doctrine\Common\Cache\zend_shm_cache_fetch() in /var/www/meediam/src/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php line 38

Finally I have configured the ArrayCache, and it works, but without cache system behind.

So the question is, Anyone know how to use Zend OpCache with Doctrine 2 Cache?

PS: I am using Symfony 2.3.2


回答1:


Adding my comment as an answer.

PHP's OpCache is not a full blown cache as APC It is a simply opcode cache. If you want to store custom data just like you would with the old APC you can use Joe Watkins' APCu: https://github.com/krakjoe/apcu.

There is also yac and memcache.




回答2:


You can actually use OpCache indirectly via PhpFileCache



来源:https://stackoverflow.com/questions/18034745/how-to-use-zendopcache-for-doctrine2-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!