Difference between revisions of "Cache API"
(3 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
<pre> | <pre> | ||
CREATE TABLE IF NOT EXISTS `cacheapi` ( | CREATE TABLE IF NOT EXISTS `cacheapi` ( | ||
+ | `dependencies` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , | ||
+ | `firstdep` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , | ||
+ | `types` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , | ||
+ | `firsttype` SMALLINT NOT NULL , | ||
`page_ids` INT(10) NOT NULL , | `page_ids` INT(10) NOT NULL , | ||
− | ` | + | INDEX ( `firstdep`(30) ) , |
− | + | INDEX ( `firsttype` ) , | |
− | + | INDEX ( `page_ids` ) | |
− | INDEX ( ` | ||
) ENGINE = MYISAM | ) ENGINE = MYISAM | ||
</pre> | </pre> | ||
− | + | ||
+ | '''Removing dependencies''' | ||
+ | ---- | ||
+ | |||
+ | To remove all dependencies of a page, use CacheAPI::remDependencies ( $idOfThePage ). | ||
+ | |||
+ | |||
+ | |||
+ | '''Adding dependencies''' | ||
+ | ---- | ||
+ | |||
+ | To add a dependency, use CacheAPI::addDependencies ( $pageid , $types, $conditions ); | ||
+ | |||
+ | $types is an array that needs to be as long as the first dimension of the 2-dimensional array $conditions. Values in $types can be : | ||
<pre> | <pre> | ||
− | + | CACHETYPE_CATEGORY | |
− | + | CACHETYPE_TEMPLATE | |
− | + | CACHETYPE_LINKSTO | |
− | + | CACHETYPE_NOTCATEGORY | |
− | + | CACHETYPE_NOTTEMPLATE | |
− | + | CACHETYPE_NOTLINKSTO | |
− | + | CACHETYPE_LINKSFROM | |
− | + | CACHETYPE_NAMESPACE | |
− | + | CACHETYPE_NOTNAMESPACE | |
− | + | CACHETYPE_OPENREFERENCES | |
− | + | CACHETYPE_LINKSTOEXTERNAL | |
− | + | CACHETYPE_IMAGEUSED | |
− | + | CACHETYPE_IMAGECONTAINER | |
+ | CACHETYPE_TEMPLATESUSEDBY | ||
+ | CACHETYPE_CREATEDBY | ||
+ | CACHETYPE_NOTCREATEDBY | ||
+ | CACHETYPE_MODIFIEDBY | ||
+ | CACHETYPE_NOTMODIFIEDBY | ||
+ | CACHETYPE_LASTMODIFIEDBY | ||
+ | CACHETYPE_NOTLASTMODIFIEDBY | ||
+ | CACHETYPE_TITLE | ||
+ | CACHETYPE_TITLESHORTERTHAN | ||
+ | CACHETYPE_TITLELONGERTHAN | ||
+ | CACHETYPE_LASTREVISIONBEFORE | ||
+ | CACHETYPE_FIRSTREVISIONSINCE | ||
+ | CACHETYPE_ALLREVISIONBEFORE | ||
+ | CACHETYPE_ALLREVISIONSINCE | ||
+ | CACHETYPE_MAXREVISIONS | ||
+ | CACHETYPE_MINREVISIONS | ||
+ | CACHETYPE_ARTICLECATEGORY | ||
+ | CACHETYPE_ORCATEGORY | ||
+ | CACHETYPE_ORTEMPLATE | ||
+ | CACHETYPE_ORLINKSTO | ||
+ | CACHETYPE_ORNOTCATEGORY | ||
+ | CACHETYPE_ORNOTTEMPLATE | ||
+ | CACHETYPE_ORNOTLINKSTO | ||
+ | CACHETYPE_ORLINKSFROM | ||
+ | CACHETYPE_ORNAMESPACE | ||
+ | CACHETYPE_ORNOTNAMESPACE | ||
+ | CACHETYPE_OROPENREFERENCES | ||
+ | CACHETYPE_ORLINKSTOEXTERNAL | ||
+ | CACHETYPE_ORIMAGEUSED | ||
+ | CACHETYPE_ORIMAGECONTAINER | ||
+ | CACHETYPE_ORTEMPLATESUSEDBY | ||
+ | CACHETYPE_ORCREATEDBY | ||
+ | CACHETYPE_ORNOTCREATEDBY | ||
+ | CACHETYPE_ORMODIFIEDBY | ||
+ | CACHETYPE_ORNOTMODIFIEDBY | ||
+ | CACHETYPE_ORLASTMODIFIEDBY | ||
+ | CACHETYPE_ORNOTLASTMODIFIEDBY | ||
+ | CACHETYPE_ORTITLE | ||
+ | CACHETYPE_ORTITLESHORTERTHAN | ||
+ | CACHETYPE_ORTITLELONGERTHAN | ||
+ | CACHETYPE_ORLASTREVISIONBEFORE | ||
+ | CACHETYPE_ORFIRSTREVISIONSINCE | ||
+ | CACHETYPE_ORALLREVISIONBEFORE | ||
+ | CACHETYPE_ORALLREVISIONSINCE | ||
+ | CACHETYPE_ORMAXREVISIONS | ||
+ | CACHETYPE_ORMINREVISIONS | ||
+ | CACHETYPE_ORARTICLECATEGORY | ||
</pre> | </pre> | ||
+ | |||
+ | For now, only Categories are fully implemented for testing but the rest is implemented as dummy and should be fully ready very soon. To avoid performance issues, we will restrict the possible first types in your array. For example, a NOT should not be used as your first type, just as 2nd or more... | ||
+ | |||
+ | $condition is a bidimensional array of category names, template names, title names, etc... | ||
− | ''' | + | |
+ | '''Example''' | ||
---- | ---- | ||
− | + | '''Example with only ANDs''' | |
+ | |||
+ | |||
+ | Say we have a DPL invocation like this : | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | {{#dpl: | ||
+ | |allowcachedresults=yes | ||
+ | |category = Test&Blablou&Papou | ||
+ | |notcategory = Mimi | ||
+ | |nottemplate = Stars | ||
+ | |include ={Test}:String | ||
+ | |format =,,, | ||
+ | |secseparators =,%PAGE%, | ||
+ | }} | ||
+ | </pre> | ||
+ | |||
+ | Then the CacheAPI should be called with the following parameters : | ||
+ | |||
+ | <pre> | ||
+ | $types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); | ||
+ | |||
+ | $conditions = array ( | ||
+ | array ( 'Test' , 'Blablou' , 'Papou' ) , | ||
+ | array ( 'Mimi' ) , | ||
+ | array ( 'Stars' ) | ||
+ | ); | ||
+ | |||
+ | CacheAPI::addDependencies ( $pageid , $types, $conditions ); | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | '''Example with ORs''' | ||
+ | |||
+ | |||
+ | Say we have a DPL invocation like this : | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | {{#dpl: | ||
+ | |allowcachedresults=yes | ||
+ | |category = Test|Blablou | ||
+ | |notcategory = Mimi | ||
+ | |nottemplate = Stars | ||
+ | |include ={Test}:String | ||
+ | |format =,,, | ||
+ | |secseparators =,%PAGE%, | ||
+ | }} | ||
+ | </pre> | ||
+ | |||
+ | Then the CacheAPI should be called 2 times with the following parameters : | ||
+ | |||
+ | <pre> | ||
+ | $types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); | ||
+ | $conditions = array ( | ||
+ | array ( 'Test' ) , | ||
+ | array ( 'Mimi' ) , | ||
+ | array ( 'Stars' ) | ||
+ | ); | ||
+ | CacheAPI::addDependencies ( $pageid , $types, $conditions ); | ||
− | |||
− | |||
− | + | $types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); | |
− | + | $conditions = array ( | |
+ | array ( 'Blablou' ) , | ||
+ | array ( 'Mimi' ) , | ||
+ | array ( 'Stars' ) | ||
+ | ); | ||
− | + | CacheAPI::addDependencies ( $pageid , $types, $conditions ); | |
+ | </pre> | ||
---- | ---- | ||
TODO : | TODO : | ||
− | + | * Implement other types of dependencies (Namespace, linksfrom, etc...) - currently being done | |
− | * Implement other types of dependencies (Namespace, linksfrom, etc...) | + | * Implement the NOTs (notcategory, notlinksto, etc...) - currently being done |
− | * 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). | * 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). | ||
− | |||
* If you need anything else, add it here. | * If you need anything else, add it here. | ||
---- | ---- | ||
Feedback and discussion moved [[Talk:Cache API|here]]. | Feedback and discussion moved [[Talk:Cache API|here]]. |
Latest revision as of 15:31, 1 August 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` ( `dependencies` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `firstdep` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `types` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `firsttype` SMALLINT NOT NULL , `page_ids` INT(10) NOT NULL , INDEX ( `firstdep`(30) ) , INDEX ( `firsttype` ) , INDEX ( `page_ids` ) ) ENGINE = MYISAM
Removing dependencies
To remove all dependencies of a page, use CacheAPI::remDependencies ( $idOfThePage ).
Adding dependencies
To add a dependency, use CacheAPI::addDependencies ( $pageid , $types, $conditions );
$types is an array that needs to be as long as the first dimension of the 2-dimensional array $conditions. Values in $types can be :
CACHETYPE_CATEGORY CACHETYPE_TEMPLATE CACHETYPE_LINKSTO CACHETYPE_NOTCATEGORY CACHETYPE_NOTTEMPLATE CACHETYPE_NOTLINKSTO CACHETYPE_LINKSFROM CACHETYPE_NAMESPACE CACHETYPE_NOTNAMESPACE CACHETYPE_OPENREFERENCES CACHETYPE_LINKSTOEXTERNAL CACHETYPE_IMAGEUSED CACHETYPE_IMAGECONTAINER CACHETYPE_TEMPLATESUSEDBY CACHETYPE_CREATEDBY CACHETYPE_NOTCREATEDBY CACHETYPE_MODIFIEDBY CACHETYPE_NOTMODIFIEDBY CACHETYPE_LASTMODIFIEDBY CACHETYPE_NOTLASTMODIFIEDBY CACHETYPE_TITLE CACHETYPE_TITLESHORTERTHAN CACHETYPE_TITLELONGERTHAN CACHETYPE_LASTREVISIONBEFORE CACHETYPE_FIRSTREVISIONSINCE CACHETYPE_ALLREVISIONBEFORE CACHETYPE_ALLREVISIONSINCE CACHETYPE_MAXREVISIONS CACHETYPE_MINREVISIONS CACHETYPE_ARTICLECATEGORY CACHETYPE_ORCATEGORY CACHETYPE_ORTEMPLATE CACHETYPE_ORLINKSTO CACHETYPE_ORNOTCATEGORY CACHETYPE_ORNOTTEMPLATE CACHETYPE_ORNOTLINKSTO CACHETYPE_ORLINKSFROM CACHETYPE_ORNAMESPACE CACHETYPE_ORNOTNAMESPACE CACHETYPE_OROPENREFERENCES CACHETYPE_ORLINKSTOEXTERNAL CACHETYPE_ORIMAGEUSED CACHETYPE_ORIMAGECONTAINER CACHETYPE_ORTEMPLATESUSEDBY CACHETYPE_ORCREATEDBY CACHETYPE_ORNOTCREATEDBY CACHETYPE_ORMODIFIEDBY CACHETYPE_ORNOTMODIFIEDBY CACHETYPE_ORLASTMODIFIEDBY CACHETYPE_ORNOTLASTMODIFIEDBY CACHETYPE_ORTITLE CACHETYPE_ORTITLESHORTERTHAN CACHETYPE_ORTITLELONGERTHAN CACHETYPE_ORLASTREVISIONBEFORE CACHETYPE_ORFIRSTREVISIONSINCE CACHETYPE_ORALLREVISIONBEFORE CACHETYPE_ORALLREVISIONSINCE CACHETYPE_ORMAXREVISIONS CACHETYPE_ORMINREVISIONS CACHETYPE_ORARTICLECATEGORY
For now, only Categories are fully implemented for testing but the rest is implemented as dummy and should be fully ready very soon. To avoid performance issues, we will restrict the possible first types in your array. For example, a NOT should not be used as your first type, just as 2nd or more...
$condition is a bidimensional array of category names, template names, title names, etc...
Example
Example with only ANDs
Say we have a DPL invocation like this :
{{#dpl: |allowcachedresults=yes |category = Test&Blablou&Papou |notcategory = Mimi |nottemplate = Stars |include ={Test}:String |format =,,, |secseparators =,%PAGE%, }}
Then the CacheAPI should be called with the following parameters :
$types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); $conditions = array ( array ( 'Test' , 'Blablou' , 'Papou' ) , array ( 'Mimi' ) , array ( 'Stars' ) ); CacheAPI::addDependencies ( $pageid , $types, $conditions );
Example with ORs
Say we have a DPL invocation like this :
{{#dpl: |allowcachedresults=yes |category = Test|Blablou |notcategory = Mimi |nottemplate = Stars |include ={Test}:String |format =,,, |secseparators =,%PAGE%, }}
Then the CacheAPI should be called 2 times with the following parameters :
$types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); $conditions = array ( array ( 'Test' ) , array ( 'Mimi' ) , array ( 'Stars' ) ); CacheAPI::addDependencies ( $pageid , $types, $conditions ); $types = array ( CACHETYPE_CATEGORY , CACHETYPE_NOTCATEGORY , CACHETYPE_NOTTEMPLATE ); $conditions = array ( array ( 'Blablou' ) , array ( 'Mimi' ) , array ( 'Stars' ) ); CacheAPI::addDependencies ( $pageid , $types, $conditions );
TODO :
- Implement other types of dependencies (Namespace, linksfrom, etc...) - currently being done
- Implement the NOTs (notcategory, notlinksto, etc...) - currently being done
- 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).
- If you need anything else, add it here.
Feedback and discussion moved here.