Difference between revisions of "Cache API"

From FollowTheScore
Jump to: navigation, search
Line 7: Line 7:
  
  
Updated : [[User:EmuWikiAdmin-|EmuWikiAdmin-]] 04:43, 1 July 2009 (UTC)
+
Updated : [[User:EmuWikiAdmin-|EmuWikiAdmin-]] 05:57, 1 July 2009 (UTC)
  
 +
 +
'''Installing'''
 +
----
  
 
For now this SQL command needs to be executed manually before installing :
 
For now this SQL command needs to be executed manually before installing :
Line 21: Line 24:
 
) ENGINE = MYISAM  
 
) ENGINE = MYISAM  
 
</pre>
 
</pre>
 +
 +
You will also need to add this to DPLMain.php :
 +
 +
<pre>
 +
 +
// update dependencies to CacheAPI whenever the page containing the DPL query is edited
 +
 +
if ($wgRequest->getVal('action','view')=='submit') {
 +
CacheAPI::remDependencies ( $wgArticle->getID());
 +
foreach ($aIncludeCategories as $categoryGroup) {
 +
foreach ($categoryGroup as $category) {
 +
$title = Title::makeTitle(14, $category);
 +
$catID = $title->getArticleID();
 +
CacheAPI::addDependencies ( $wgArticle->getID(), 1, $catID, '');
 +
// die ("adding to DEPENDENCIES: ".$title->getArticleID());
 +
}
 +
}
 +
}
 +
</pre>
 +
  
 
'''Removing dependencies'''
 
'''Removing dependencies'''
 
----
 
----
  
To remove all dependencies of a page, use CacheAPI::remDependencies ( idOfThePage ).
+
To remove all dependencies of a page, use CacheAPI::remDependencies ( $idOfThePage ).
 +
 
  
  
Line 31: Line 55:
 
----
 
----
  
To add a dependency, use CacheAPI::addDependencies ( pageid , type, condition, '');
+
To add a dependency, use CacheAPI::addDependencies ( $pageid , $type, $conditions, '');
  
 
type 1 = category, 2 = template, 3 = linksto
 
type 1 = category, 2 = template, 3 = linksto
  
condition is an array of category names (to be switched to an array of category numbers, see discussion below).
+
condition is an array of category ids (to be switched to an array of category numbers, see discussion below).
  
 
----
 
----
 
TODO :  
 
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 other types of dependencies (Namespace, linksfrom, etc...)
 
* Implement the NOTs (notcategory, notlinksto, etc...)
 
* Implement the NOTs (notcategory, notlinksto, etc...)
* Make a better system for deleation of dependencies (right now, the only thing you can do is delete ALL dependencies related to a page at once)
+
* 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...)
 
* Implement cache outdating when special events other than edit/create are performed (deletion, rename, etc...)
 
* If you need anything else, add it here.
 
* If you need anything else, add it here.
 +
----
 +
 +
Feedback and discussion moved [[Talk:Cache API|here]].

Revision as of 07:57, 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()); 
			foreach ($aIncludeCategories as $categoryGroup) {
				foreach ($categoryGroup as $category) {
					$title = Title::makeTitle(14, $category);
					$catID = $title->getArticleID();
					CacheAPI::addDependencies ( $wgArticle->getID(), 1, $catID, ''); 
					// die ("adding to DEPENDENCIES: ".$title->getArticleID());
				}
			}
		}


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.