Zend Metadata Cache in file
Posted
by
Matthieu
on Stack Overflow
See other posts from Stack Overflow
or by Matthieu
Published on 2012-08-12T10:14:59Z
Indexed on
2012/09/05
9:38 UTC
Read the original article
Hit count: 139
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).
© Stack Overflow or respective owner