Quantcast

Caching xml files with Zend_Cache

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Caching xml files with Zend_Cache

GJ Bogaerts
Hi all,

I'm having trouble figuring out how to cache a config.xml for my ZF application. I should use 'File' as the frontend, but how do I pass the environment variable to the cache? Should I be using different XML configuration files in order to accomodate either my development, testing and staging environments? That doesn't seem right.

In other words, how do I best cache this config object using File as the Zend_Cache frontend?

self::$_config = new Zend_Config_Xml("{$this->_root}/application/config.xml", $this->_env);

Thanks for your input and help!

GJ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Figured it out, Re: Caching xml files with Zend_Cache

GJ Bogaerts
Never mind, I figured it out. Makes sense, of course...

        $configPath = $this->_root . '/application/config.xml';
        $frontend = array(
            'master_files' => array(
                $configPath),
            'automatic_serialization' => true);
        $backend = array();
        $cache = Zend_Cache::factory('File', 'Memcached', $frontend, $backend);
        if (! ($config = $cache->load('configXml'))) {
            $config = new Zend_Config_Xml($configPath, $this->_env);
            $cache->save($config, 'configXml');
        }

GJ Bogaerts wrote
Hi all,

I'm having trouble figuring out how to cache a config.xml for my ZF application. I should use 'File' as the frontend, but how do I pass the environment variable to the cache? Should I be using different XML configuration files in order to accomodate either my development, testing and staging environments? That doesn't seem right.

In other words, how do I best cache this config object using File as the Zend_Cache frontend?

self::$_config = new Zend_Config_Xml("{$this->_root}/application/config.xml", $this->_env);

Thanks for your input and help!

GJ
Loading...