Hi, thanks for the response.

Not sure this is exactly what I had in mind.

ZF manual contains the following example:

---------------8<------------------------

class test {
    public function foobar2($param1, $param2) {...}
}

$frontendOptions = array(
    'cached_entity' => new test() // An instance of the class
);

$cache = Zend_Cache::factory(...);

# The cached call
$res = $cache->foobar2('1', '2');

---------------8<------------------------

This is all fine and dandy when you're interested in any method other than a
constructor.

However, I am trying to cache the class that's instantiated based on
*mandatory* constructor parameters, and it may not have any other methods:

$_myClass = new myClass($a, b);

So, I figured it should say:

$frontendOptions = array(
    'cached_entity' => new myClass($a, b) // An instance of the class
);

$cache = Zend_Cache::factory('Class', 'File', $frontendOptions,
$backendOptions);

The problem is, how should I use $cache to fetch cached instance of
$myClass?

Temuri


Josh Team wrote:
> 
> I use the Registry for this. So in your bootstrap:
> 
> Zend_Registry::set('cache', Zend_Cache::factory( ... ));
> 
> then in your action or wherever:
> 
> Zend_Registry::get('cache')->save($var, 'var');
> Zend_Registry::get('cache')->load('var')
> 
> Hope this helps!
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Cache-with-%27Class%27-frontend---problem-with-__construct%28%24a%2C-%24b%29-tp18834887p18835410.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to