[pmwiki-devel] Are page text variables cached?

marc gmane at auxbuss.com
Tue Nov 28 03:57:00 CST 2006


Wanting to reduce page reads to a minimum, I am trying to decide whether 
I should put multiple page text variables on a single page, say:

  Site.Variables

or place the page text variables on the page that relates to the 
variable.

For example, from a performance POV, would it be better to have

  Site.PriceList

or place the price on the product page as a page text variable?

That's Part I.

Part II is to help me understand the related code.

  function PageTextVar($pagename, $var)
    global $PCache, $PageTextVarPatterns;
    if (!@$PCache[$pagename]['=pagetextvars']) {
      $pc = &$PCache[$pagename];
      $pc['=pagetextvars'] = 1;
      $page = RetrieveAuthPage($pagename, 'read', false, 
READPAGE_CURRENT);
      if ($page) {
        foreach((array)$PageTextVarPatterns as $pat) 
          if (preg_match_all($pat, $page['text'], $match, 
PREG_SET_ORDER))
            foreach($match as $m)  
              $pc["=p_{$m[1]}"] = Qualify($pagename, $m[2]);
      }
    }
    return $PCache[$pagename]["=p_$var"];
  }

The first if statement seems to answer my question above. Is this doing 
what I think it's doing? Namely, caching all the page text vars for a 
page.

Does '=' in ['=pagetextvars'] have a purpose, or is it simply a naming 
convention?

Is there a write-up about $PCache?

Thanks.

-- 
Best,
Marc




More information about the pmwiki-devel mailing list