如何将 ZendOpCache 用于 Doctrine2 缓存?
我已经在我的开发环境中安装了 PHP 5.5.1,并且还配置了 Zend OpCache 作为缓存提供者.一切都在使用新版本和设置的服务器上运行,但在我的 symfony 2 项目中,我有 Doctine2 缓存来存储一些静态"数据(国家、语言等),但它不适用于 Opcache.
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.
直到今天,我还在使用 DoctrineCommonCacheApcCache 使用 APC 处理 Doctrine2 缓存的类,但似乎不存在使用 OpCache 的类.
Until today, I was using the DoctrineCommonCacheApcCache class to work with the cache of Doctrine2 using APC, but seems that does not exists a class to work with OpCache.
这是我的 APC 缓存的 config.yml:
This is my config.yml for APC cache:
# Services
services:
cache:
class: DoctrineCommonCacheApcCache
现在,使用 OpCache 我尝试使用 ZendDataCache 来处理缓存系统,但不起作用:
Now, with OpCache I have tried to use ZendDataCache to deal with cache system, but does not work:
# Services
services:
cache:
class: DoctrineCommonCacheendDataCache
我收到此错误,因此我假设 ZendDataCache 类不适用于 OpCache:
I get this error, so I assume that ZendDataCache class is not for OpCache:
FatalErrorException: Error: Call to undefined function DoctrineCommonCachezend_shm_cache_fetch() in/var/www/meediam/src/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php line 38
FatalErrorException: Error: Call to undefined function DoctrineCommonCachezend_shm_cache_fetch() in /var/www/meediam/src/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php line 38
最后我配置了 ArrayCache,它可以工作,但没有缓存系统落后.
Finally I have configured the ArrayCache, and it works, but without cache system behind.
所以问题是,有人知道如何将 Zend OpCache 与 Doctrine 2 Cache 结合使用吗?
PS:我使用的是 Symfony 2.3.2
推荐答案
添加我的评论作为答案.
PHP 的 OpCache 不像 APC 那样是一个完整的缓存,它只是一个简单的操作码缓存.如果您想像使用旧 APC 一样存储自定义数据,您可以使用 Joe Watkins' APCu:https://github.com/krakjoe/apcu.
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.
还有 yac 和 memcache.
There is also yac and memcache.
相关文章