r91540 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91539‎ | r91540 | r91541 >
Date:09:12, 6 July 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
limit maximum size of new cache
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStore2IdCache.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStore2IdCache.php
@@ -43,6 +43,7 @@
4444 'smw_subobject' => $subobject );
4545 $row = $this->m_db->selectRow( 'smw_ids', 'smw_id', $condition, __METHOD__);
4646
 47+ $this->checkForSizeLimit();
4748 if ( $row !== false ) {
4849 $this->m_data[$hashKey] = $row->smw_id;
4950 return $row->smw_id;
@@ -64,6 +65,7 @@
6566
6667 public function setId( $title, $namespace, $interwiki, $subobject, $id ) {
6768 $hashKey = self::getHashKey( $title, $namespace, $interwiki, $subobject );
 69+ $this->checkForSizeLimit();
6870 $this->m_data[$hashKey] = $id;
6971 if ( $interwiki == SMW_SQL2_SMWREDIIW ) {
7072 $hashKey = self::getHashKey( $title, $namespace, '', $subobject );
@@ -86,6 +88,12 @@
8789 $this->m_data = array();
8890 }
8991
 92+ protected function checkForSizeLimit() {
 93+ if ( count( $this->m_data ) > 1000 ) {
 94+ $this->clear();
 95+ }
 96+ }
 97+
9098 protected static function getHashKey( $title, $namespace, $interwiki, $subobject ) {
9199 return "$title#$namespace#$interwiki#$subobject";
92100 }