Zend Metadata Cache in file
- by Matthieu
I set up a metadata cache in Zend Framework because a lot of DESCRIBE queries were executed and it affected the performances.
$frontendOptions = array ('automatic_serialization' => true);
$backendOptions = array ('cache_dir' => CACHE_PATH . '/db-tables-metadata');
$cache = Zend_Cache::factory(
'Core',
'File',
$frontendOptions,
$backendOptions
);
Zend_Db_Table::setDefaultMetadataCache($cache);
I can indeed see the cache files created, and the website works great.
However, when I launch unit tests, or a script of the same application that perform DB queries, I end up with an error because Zend couldn't read the cache files.
This is because in the website, the cache files are created by the www user, and when I run phpunit or a script, it tries to read them with my user and it fails.
Do you see any solution to that? I have some quickfix ideas but I'm looking for a good/stable solution. And I'd rather avoid running phpunit or the scripts as www if possible (for practical reasons).