This is probably a dumb question, but I'm looking for a way to call a bootstrap resource from a model (in this case is a Zend_Cache object).

Bootstrap method:

    protected function _initCache()
    {
        $frontendOptions = array(
           'lifetime' => 7200, // cache lifetime of 2 hours
           'automatic_serialization' => true
        );

        $cachedir = realpath(/path/to/cache');
        $backendOptions = array(
            'cache_dir' => $cachedir
        );

        $cache = Zend_Cache::factory('Core',
                             'File',
                             $frontendOptions,
                             $backendOptions);
        Zend_Registry::set('Zend_Cache',$cache);
        return $cache;
    }

Obviously this is set into the registry so I can access it that way, but I was wondering if this is the best way to do it, or whether there was some way of calling it like you do in a controller:

$this->_cache = $this->getInvokeArg('bootstrap')->getResource('Cache');

or maybe even passing it directly over to the __construct of the model.

Any advice greatly appreciated

Reply via email to