Fork me on GitHub

cached  Bottom

  • Code

    // check out if the contents are cached.
        // If this is the case, we do not need to make DB queries.
        // Note that we print out "cached:" in front of a chached output --
        // of course, this is here to illustrate caching and needs to be removed!
        if ($pnRender->is_cached('mymod_user_display.htm')) {
           return 'cached:<br />' . $pnRender->fetch('mymod_user_display.htm');
        }


    I have this code in my module. In the comment it says "and needs to be removed" Does that mean the caching needs to be removed or this piece of code?

    I'm guessing it's the code, but still a little unsure.
  • The code...unless you're planning to use caching, that is.
  • No, what the comment really means is that you don't want to print the word "cached' in front of the cache content so once debugging is OK, you should change :

    Code

    return 'cached:<br />' . $pnRender->fetch('mymod_user_display.htm');

    to :

    Code

    return $pnRender->fetch('mymod_user_display.htm');

    But I found the addition of the 'cached' word very usefull while debugging my modules to see if the content come from the cache or not !!!

    --
    Visit my live reef aquarium.

    My Amazon wish list.

This list is based on users active over the last 60 minutes.