本文介绍了如何使用ZendOpCache进行Doctrine2缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的开发环境中安装了PHP 5.5.1,并且还配置了Zend OpCache作为缓存提供程序。一切都在服务器上使用新版本和设置,但在我的symfony 2项目中,我有Doctine2缓存来存储一些静态数据(国家,语言等),而不适用于Opcache。



直到今天,我使用的是类使用APC使用Doctrine2的缓存,但似乎不存在使用OpCache的类。



这是我的APC缓存的config.yml:

 #服务
服务:
缓存:
class:Doctrine\Common\Cache\ApcCache

现在,使用OpCache我尝试过使用来处理缓存系统,但不起作用:

 #服务
服务:
缓存:
类:Doctr ine\Common\Cache\ZendDataCache

我收到这个错误,所以我假设ZendDataCache类不适用于OpCache:

最后我已经配置了,它的工作原理,但没有缓存系统。



所以问题是,
任何人都知道如何使用Zend OpCache与Doctrine 2 Cache?



PS:我正在使用Symfony 2.3.2

解决方案

em添加我的评论作为一个答案。



PHP的OpCache不是一个完整的缓存作为APC它是一个简单的操作码缓存。如果您想像旧版APC一样存储自定​​义数据,您可以使用 APCu: a href =https://github.com/krakjoe/apcu =nofollow noreferrer> https://github.com/krakjoe/apcu 。



还有和memcache。


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:

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

解决方案

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.

这篇关于如何使用ZendOpCache进行Doctrine2缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 17:47