Difference between revisions of "Cache API"
Line 28: | Line 28: | ||
<pre> | <pre> | ||
− | |||
// update dependencies to CacheAPI whenever the page containing the DPL query is edited | // update dependencies to CacheAPI whenever the page containing the DPL query is edited | ||
if ($wgRequest->getVal('action','view')=='submit') { | if ($wgRequest->getVal('action','view')=='submit') { | ||
CacheAPI::remDependencies ( $wgArticle->getID()); | CacheAPI::remDependencies ( $wgArticle->getID()); | ||
− | foreach ($aIncludeCategories as $ | + | $categorylist = array(); |
− | foreach ($ | + | foreach ($aIncludeCategories as $categorygroup) { |
− | $ | + | foreach ($categorygroup as $category) { |
− | + | $catobj = Category::newFromName( $category ); | |
− | + | array_push ( $categorylist , $catobj->getID() ); | |
− | |||
} | } | ||
} | } | ||
+ | CacheAPI::addDependencies ( $wgArticle->getID(), 1, $categorylist, ''); | ||
} | } | ||
+ | |||
</pre> | </pre> | ||
Revision as of 06:58, 1 July 2009
This is a development page for the Cache API that we are currently implementing. Talk to EmuWikiAdmin- for more information.
Manual
We have a somewhat working version here : http://www.emuwiki.com/testinstall/extensions/CacheAPI_current.txt
Updated : EmuWikiAdmin- 05:57, 1 July 2009 (UTC)
Installing
For now this SQL command needs to be executed manually before installing :
CREATE TABLE IF NOT EXISTS `cacheapi` ( `page_ids` INT(10) NOT NULL , `dependencies` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `first` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `type` INT(10) NOT NULL , INDEX ( `page_ids` , `dependencies`(40) , `first`(40) , `type` ) ) ENGINE = MYISAM
You will also need to add this to DPLMain.php :
// update dependencies to CacheAPI whenever the page containing the DPL query is edited if ($wgRequest->getVal('action','view')=='submit') { CacheAPI::remDependencies ( $wgArticle->getID()); $categorylist = array(); foreach ($aIncludeCategories as $categorygroup) { foreach ($categorygroup as $category) { $catobj = Category::newFromName( $category ); array_push ( $categorylist , $catobj->getID() ); } } CacheAPI::addDependencies ( $wgArticle->getID(), 1, $categorylist, ''); }
Removing dependencies
To remove all dependencies of a page, use CacheAPI::remDependencies ( $idOfThePage ).
Adding dependencies
To add a dependency, use CacheAPI::addDependencies ( $pageid , $type, $conditions, );
type 1 = category, 2 = template, 3 = linksto
condition is an array of category ids (to be switched to an array of category numbers, see discussion below).
TODO :
- Switch from using page names (linksto) and template names (template) to using pages ids and template ids, like we did with categories. If possible.
- Implement other types of dependencies (Namespace, linksfrom, etc...)
- Implement the NOTs (notcategory, notlinksto, etc...)
- Make a better system for deletion of dependencies (right now, the only thing you can do is delete ALL dependencies related to a page at once, this is not good for pages with multiple DPL invocations).
- Implement cache outdating when special events other than edit/create are performed (deletion, rename, etc...)
- If you need anything else, add it here.
Feedback and discussion moved here.