Fork me on GitHub

Some questions about cache  Bottom

  • Hello,

    I've some questions about the cache:

    1. A cache file is created using the current language, theme and module. Is it possible to add a var name to this file?
    2. I'm using a same template file for many module but the content of this template vary a lot, depending of the module to display. So if I use cache for this template, the cache will be register with the module A and if I try after that to display the content of the module B, it will display the cache file of the module A?
    3. Same question as question 2, with only one module but with a display that may change a lot depending of the group permissions.
  • Ad 1. You may use cache_id property of Renderer object. It allows you to add to cache identifier some custom values, eg user id or whatever you need.
    In menutree I've used user id to differentiate cache for users due to user based permissions:
    http://code.zikula.org/bianor/browser/trunk/menutree/modules/menutree/pnblocks/menutree.php#L42
    (the same solution is in extmenu)

    Ad 2. The same template for different modules should work fine. Renderer always build cache_id using base URL, module name and optional cache_id provided by module author. So the same tpl for different modules should have different cache id's

    Ad 3. The same as point 1 - use cache_id property and add to it group ids.

    --
    Polish Zikula Team
    Bianor Works - my Zikula works on CoZi
  • Thank you Jusuff! I've all the information that I need, I will add to cache identifier some custom values. icon_wink
  • I've a new question about the cache, I try to override the system value of the cache. If the cache is disable, I do this to force it:

    Code

    $render =& pnRender::getInstance('Sitemap');
        $cachest_default = pnModGetVar('pnRender', 'cache');

        if ($smconf['cachest'] == 1) {
            if ($cachest_default == 0) {
                // Force caching
                $render->caching    = 1;
            }
            // Set cache lifetime
            $render->cache_lifetime = $smconf['cachelt'];
        }


    That's work, after that I fetch the template, then disable the cache:

    Code

    $return = $render->fetch('sitemap_user_view.html');

        // Recover cache state/information
        if ($smconf['cachest'] == 1 && $cachest_default == 0) {
            $render->caching = 0;
        }

        return $return;


    The first time that this function is load, it's ok, the cache is created only for the sitemap module. But after that, when this function is load, the cache is enable for all the website... :(



    edited by: Yokav, datetimebrief

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