initial support for partial message cache, the way to have separated message
authorDomas Mituzas <midom@users.mediawiki.org>
Mon, 4 Oct 2004 20:36:11 +0000 (20:36 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Mon, 4 Oct 2004 20:36:11 +0000 (20:36 +0000)
cache objects by scope and/or severity, though by leaving rarely used messages
standalone on db and/or cached daemons...

includes/DefaultSettings.php
includes/MessageCache.php
includes/MessageCacheHints.php [new file with mode: 0644]

index ea89a14..f22f41b 100644 (file)
@@ -301,8 +301,7 @@ $wgTranslateNumerals = true; # For Hindi and Arabic use local numerals instead
 # Interface messages will be get from the database.
 $wgUseDatabaseMessages = true;
 $wgMsgCacheExpiry      = 86400;
-
-
+$wgPartialMessageCache = false;
 # Miscellaneous configuration settings
 #
 
index e5a89e9..fd6ae56 100755 (executable)
@@ -117,16 +117,24 @@ class MessageCache
        }
 
        /**
-        * Loads all cacheable messages from the database
+        * Loads all or main part of cacheable messages from the database
         */
        function loadFromDB() {
-                       $fname = 'MessageCache::loadFromDB';
+               global $wgPartialMessageCache;
+               $fname = 'MessageCache::loadFromDB';
                $dbr =& wfGetDB( DB_SLAVE );
+               $conditions = array( 'cur_is_redirect' => 0, 
+                                       'cur_namespace' => NS_MEDIAWIKI);
+               if ($wgPartialMessageCache) {
+                       if (is_array($wgPartialMessageCache)) {
+                               $conditions['cur_title']=$wgPartialMessageCache;
+                       } else {
+                               require_once("MessageCacheHints.php");
+                               $conditions['cur_title']=MessageCacheHints::get();
+                       }
+               }
                $res = $dbr->select( 'cur',
-                       array( 'cur_title', 'cur_text' ),
-                       array( 'cur_is_redirect' => 0, 'cur_namespace' => NS_MEDIAWIKI ),
-                       $fname
-               );
+                       array( 'cur_title', 'cur_text' ), $conditions, $fname);
 
                $this->mCache = array();
                for ( $row = $dbr->fetchObject( $res ); $row; $row = $dbr->fetchObject( $res ) ) {
diff --git a/includes/MessageCacheHints.php b/includes/MessageCacheHints.php
new file mode 100644 (file)
index 0000000..d84e247
--- /dev/null
@@ -0,0 +1,16 @@
+<?
+
+/* 
+ *     @package Mediawiki
+ *     @version $Id$
+ *
+ *     This class should provide methods for message 
+ *     cache key hints for various scopes */
+
+class MessageCacheHints {
+       function get($scope="global") {
+               return array('TODO');
+       }
+}
+
+?>