Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ZendOpCache for Doctrine2 cache?

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

like image 920
unairoldan Avatar asked Aug 03 '13 16:08

unairoldan


1 Answers

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.

like image 88
PeeHaa Avatar answered Sep 30 '22 07:09

PeeHaa