Still no answers to my questions. No one has any insight?

If you cache the whole action ( $cacheAction) then is it to assume you don't
need to cache the query data or the view since the whole action is cached as
1 object? Does 1 cache take precedent over another. The actual action in the
controller is never hit (if already cached) so you would not need to cache
the query data in that action?

Function view ($id) {

//Read cache if empty get the data needed and cache the query data

$cache_data = Cache::read($cache_name);
if (empty($cache_data))
{
        $dataModel = $this->Model->find('first');
        Cache::write($cache_name, $dataModel, array('config' => 'File',
'duration' => 7200)); //if the action is cached do you need to cache this
data at all?
}
else
{
        $dataModel = $cache_data;
}




}

Thanks to anyone who might have some insight!

K

-----Original Message-----
From: Krissy Masters [mailto:[email protected]] 
Sent: Thursday, April 07, 2011 9:47 PM
To: '[email protected]'
Subject: Cache Confusion

Cache action, query and view/element. So how do you know which to use, when?

Basic example we use Post action => view,  id => 123

We cache the query data from the database so every time that Post is viewed
we simply read the cached data, fine easy enough delete that data cache on
update so we always pull new data.

***But***

If the action is cached do we need to cache the query data also? The view
holds the data so if the view is cached as the final product does cake still
try to get the database query. I guess think of a cascade effect if the
action is cached for x amount of time does that override the view and query
cache since that action and the query inside the action would not even be
run since the total "action" and everything inside is cached whatever is
inside the action should be skipped all together no?

$cacheAction as it sounds would cache everything the action does, all its
thinking, data requests and result if your caching the whole action then you
don't need to cache anything else?

Cacheing you query is just the data from the db in a file / memory wherever
you save it

View just the rendered output with the query data in it

$cacheAction = view/123 => 1 month whatever for a rough example


function view ($id) {

//after initial first time viewing of this page everything inside here would
be completely skipped?
If your caching the total actions end result why would you cache the query
data? Would it not be cached inside the action already?

}

I guess with the available options it can be a bit confusing and knowing
when to use with what and when.

Any insight to clear this up would be great.

Thanks all,

K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to