I already have a response for my own post here.

It turns out that in the Cache::read within my view I was not naming
the cache configuration, that is to say I was doing:-
$data = Cache::read('cache_name');

I've discovered that I needed to do:-
$data = Cache::read('cache_name','config_name');

When the original data was inserted into the cache with:-
Cache::write('cache_name',$data,'config_name');

I *suspect* the problem may have something to do with the fact that
within my application I'm calling Cache::read and Cache::write with
different configurations on the same request and there is some
internal Cache:: object variable that is getting set and remembered
within that request -- anyway just a guess.

Anyway the lesson is to be sure to name your cache configurations I
guess.

N


On May 18, 11:56 am, NdJ <[email protected]> wrote:
> Hi,
>
> I've bumped into some unexpected behavior when pulling cache data
> using a named cache config setting from within a view.
>
> For example:-
>
> In core.php I have something like this:-
> $cache_method = 'Apc'
> Cache::config('short',array('engine'=>
> $cache_method,'duration'=>'300'));
> Cache::config('medium',array('engine'=>
> $cache_method,'duration'=>'900'));
> Cache::config('long',array('engine'=>
> $cache_method,'duration'=>'3600'));
> Cache::config('default',array('engine'=>
> $cache_method,'duration'=>'180'));
>
> Which works great when I use those config names for Cache::read and
> Cache::write within  models and controllers.
>
> Unfortunately when I use those Cache methods using config names within
> a view I get a cache miss which when you are trying to wrap a
> requestAction() is less than ideal -- I note that the object does get
> written to the cache as I can see it (with APC info) but it seems
> calling it back fails.
>
> But here is the important twist -- if I use the Cache config name
> 'default' (our just leave it out) all works as expected.
>
> Am I missing something special I need to do in order to cache data
> within a view or is this an issue?
>
> Ahh, and I additionally note that <app>/tmp/cache/views is becoming
> populated with elements that I've called via 
> $this->element('foobar',array('cache'=>array('key'=>'foobar','time'=>'+10
>
> minutes'))) -- I was expecting to find those in the memory cache.
>
> Cheers,
> N
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to