LinkCache.doc (MediaWiki): Difference between revisions

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
No edit summary
 
m belated post-import cleanup
Line 1: Line 1:
[[Techniques]]:
[[Techniques]]: Software: [[MediaWiki]]: [[MediaWikiDoc:Developer Documents|Developer Documents]]: [[MediaWikiDoc:LinkCache.doc|LinkCache.doc]]
Software: [[MediaWiki]]: [[MediaWikiDoc:Developer Documents|Developer
Documents]]: [[MediaWikiDoc:LinkCache.doc|LinkCache.doc]]
==Contents==
==Contents==
The LinkCache class maintains a list of article titles and the
The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database. This is used to mark up links when displaying a page. If the same link appears more than once on any page, then it only has to be looked up once.  
information about whether or not the article exists in the database.
This is used to mark up links when displaying a page. If the same link
In practice, what happens is that the global cache object $wgLinkCache is consulted and updated every time the function getArticleID() from Title is called.  
appears more than once on any page, then it only has to be looked up
once. In practice, what happens is that the global cache object
This has a side benefit that we take advantage of. We have tables "links" and "brokenlinks" which we use to do things like the Orphans page and Whatlinkshere page. It just so happens that after we update a page, we display it – and as we're displaying it, we look up all the links on that page, causing them to be put into the cache. That information is exactly what we need to update those two tables. So, we do something tricky when we update pages: just after the update and before we display, we clear the cache. Then we display the updated page. Finally, we put a LinksUpdate object onto the deferred updates list, which fetches its information from the cache.  
$wgLinkCache is consulted and updated every time the function
getArticleID() from Title is called. This has a side benefit that we
There's a minor complication: displaying a page also looks up a few things like the talk page link in the quick bar and the date links. Since we don't want those in the link tables, we must take care to suspend the cache while we look those up. Skin.php does exactly that – see dateLink(), for example.  
take advantage of. We have tables "links" and "brokenlinks" which we
==Edit Log==
use to do things like the Orphans page and Whatlinkshere page. It just
so happens that after we update a page, we display it – and
as we're displaying it, we look up all the links on that page, causing
them to be put into the cache. That information is exactly what we need
to update those two tables. So, we do something tricky when we update
pages: just after the update and before we display, we clear the cache.
Then we display the updated page. Finally, we put a LinksUpdate object
onto the deferred updates list, which fetches its information from the
cache. There's a minor complication: displaying a page also looks up a
few things like the talk page link in the quick bar and the date links.
Since we don't want those in the link tables, we must take care to
suspend the cache while we look those up. Skin.php does exactly that
– see dateLink(), for example. ==Edit Log==
*'''2005-06-13''' Transcribed from docs for MediaWiki version 1.4.5
*'''2005-06-13''' Transcribed from docs for MediaWiki version 1.4.5

Revision as of 02:18, 2 December 2005

Techniques: Software: MediaWiki: Developer Documents: LinkCache.doc

Contents

The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database. This is used to mark up links when displaying a page. If the same link appears more than once on any page, then it only has to be looked up once.

In practice, what happens is that the global cache object $wgLinkCache is consulted and updated every time the function getArticleID() from Title is called.

This has a side benefit that we take advantage of. We have tables "links" and "brokenlinks" which we use to do things like the Orphans page and Whatlinkshere page. It just so happens that after we update a page, we display it – and as we're displaying it, we look up all the links on that page, causing them to be put into the cache. That information is exactly what we need to update those two tables. So, we do something tricky when we update pages: just after the update and before we display, we clear the cache. Then we display the updated page. Finally, we put a LinksUpdate object onto the deferred updates list, which fetches its information from the cache.

There's a minor complication: displaying a page also looks up a few things like the talk page link in the quick bar and the date links. Since we don't want those in the link tables, we must take care to suspend the cache while we look those up. Skin.php does exactly that – see dateLink(), for example.

Edit Log

  • 2005-06-13 Transcribed from docs for MediaWiki version 1.4.5