Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2010-03-26 18:34:46

alessio
Member
Registered: 2009-08-07
Posts: 27

read variable on bootstrarp

I have insert on bootstrap this function and variable for cache:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    public $cahce ;

    protected function _initCache()
    {
        // Cache options
        $frontendOptions = array(
           'lifetime' => 86400*2,                      // Cache lifetime of 20 minutes
           'automatic_serialization' => true,
           'cache_id_prefix' => 'meme',
        );
        $backendOptions = array(
            'cache_dir' => '../application/meme-tmp/',   // Directory where to put the cache files
        );
        
        //se non è abilitato APC usa file
        $backend = extension_loaded('apc') ? 'Apc' : 'File';

        // Get a Zend_Cache_Core object
        $this->cache = Zend_Cache::factory('Core', $backend, $frontendOptions, $backendOptions);
       
         //Zend_Db_Table_Abstract::setDefaultMetadataCache($this->cache);  
       
     }

can i read the variable $cache from the models ??

Offline

#2 2010-03-28 16:32:37

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: read variable on bootstrarp

hey Alessio,

you could store the variable in Zend_Registry and pick it up on the other side, or create a singleton and then call a getInstance() method on it... Alternatively, I believe if you return $this->cache, you can pick it up as an environment argument in your controller and pass it into your model that way. A singleton is probably the best way to go... e.g. MyApp_CacheFactory::getInstance()

my 2 cents,
-
Jon

Offline

Board footer

Powered by FluxBB