On Thu, Nov 10, 2011 at 1:04 AM, Stephan Gambke <[email protected]> wrote:

>
> S*mantic Forms form definition pages work to a degree similar to
> templates, in that they have some explanatory text in <noinclude> tags
> and the actual form definition in <includeonly> tags. Currently this
> form definition is parsed every time a form is requested. I would like
> to cache it. As I understood it, I can do that by setting a property
> on the form definition page's ParserOutput object. So my idea was,
> whenever there is a cache miss on the form definition page I parse the
> part in <includeonly> tags and cache it along with the page. Then,
> when a form is actually to be displayed I get the form definition text
> from cache if available.
>

Since the <noinclude> contents are excluded in an early stage of parsing,
it probably doesn't make sense to hook into the parser or parser cache here.

A more typical caching pattern within MediaWiki would look something like
this:

* devise an appropriate cache key involving the form's id or title, eg
wfCacheKey( 'formdata', $page->articleId() );
* at times when you would fetch the form definition data, first pull that
key from cache
** if cache hit, use that data
** if cache miss, fall through to existing article fetch & form definition
parsing
*** after generating that data, save it to cache
* when form pages are saved anew, delete the cache entry so it can be
regenerated with fresh data

You can grab caches from wfGetMainCache() and friends (by default the main
cache is a null-op, whereas wfGetParserCacheStorage() will to go the
objectcache table if something like memcache isn't being used, so will
always actually store stuff).

-- brion
_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to