2011/4/9 Platonides Platonides@gmail.com:
Yes. Calling a template twice will only fetch the text once, won't increase the 'used templates' counter... Preprocessing of wikitext over a threshold is cached serialized (it's easier to reprocess if it's too small).
To clarify: there's an in-process cache, like Brion said, so a template that is used twice on the same page is only fetched and preprocessed once. However, this only applies to templates called with no parameters. If the template is passed parameters, this in-process cache won't be used, even if the same set of parameters is used twice.
What we store in memcached is a serialized version of the preprocessor XML tree, keyed on the MD5 hash of the wikitext input, unless it's too small, like Platonides said. This means that if the exact same input is fed to the preprocessor twice, it will do part of the work only one and cache the intermediate result.
Roan Kattouw (Catrope)