Difference between revisions of "Cache API"

From FollowTheScore
Jump to: navigation, search
Line 57: Line 57:
 
To add a dependency, use CacheAPI::addDependencies ( $pageid , $type, $conditions, '');
 
To add a dependency, use CacheAPI::addDependencies ( $pageid , $type, $conditions, '');
  
type 1 = category, 2 = template, 3 = linksto
+
Type can be :
 +
 
 +
CACHETYPE_CATEGORY if you want the cache of article $pageid to be dependent on articles being touched in the categories $conditions
 +
 
 +
CACHETYPE_TEMPLATE if you want the cache of article $pageid to be dependent on articles being touched and containing templates $conditions
 +
 
 +
CACHETYPE_LINKSTO if you want the cache of article $pageid to be dependent on articles being touched and containing links to page $conditions
 +
 
 +
 
 +
$condition is an array of category ids (numbers) or template names (strings).
  
condition is an array of category ids.
 
  
 
----
 
----

Revision as of 20:56, 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 can be :

CACHETYPE_CATEGORY if you want the cache of article $pageid to be dependent on articles being touched in the categories $conditions

CACHETYPE_TEMPLATE if you want the cache of article $pageid to be dependent on articles being touched and containing templates $conditions

CACHETYPE_LINKSTO if you want the cache of article $pageid to be dependent on articles being touched and containing links to page $conditions


$condition is an array of category ids (numbers) or template names (strings).



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.