Reorganization of SearchEngine for legibility
[lhc/web/wiklou.git] / includes / ObjectCache.php
index 53e947c..ecbf731 100644 (file)
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 # http://www.gnu.org/copyleft/gpl.html
-
-# Simple generic object store
-# interface is intended to be more or less compatible with
-# the PHP memcached client.
-#
-# backends for local hash array and SQL table included:
-#  $bag = new HashBagOStuff();
-#  $bag = new MysqlBagOStuff($tablename); # connect to db first
-
-class /* abstract */ BagOStuff {
+/**
+ *
+ * @package MediaWiki
+ */
+/**
+ * Simple generic object store
+ *
+ * interface is intended to be more or less compatible with
+ * the PHP memcached client.
+ *
+ * backends for local hash array and SQL table included:
+ * $bag = new HashBagOStuff();
+ * $bag = new MysqlBagOStuff($tablename); # connect to db first
+ *
+ * @package MediaWiki
+ * @abstract
+ */
+class BagOStuff {
        var $debugmode;
        
        function BagOStuff() {
@@ -142,7 +151,11 @@ class /* abstract */ BagOStuff {
 }
 
 
-/* Functional versions! */
+/**
+ * Functional versions!
+ * @todo document
+ * @package MediaWiki
+ */
 class HashBagOStuff extends BagOStuff {
        /*
           This is a test of the interface, mainly. It stores
@@ -194,8 +207,15 @@ CREATE TABLE objectcache (
   key (exptime)
 );
 */
-class /* abstract */ SqlBagOStuff extends BagOStuff {
+
+/**
+ * @todo document
+ * @abstract
+ * @package MediaWiki
+ */
+class SqlBagOStuff extends BagOStuff {
        var $table;
+
        function SqlBagOStuff($tablename = 'objectcache') {
                $this->table = $tablename;
        }
@@ -242,9 +262,13 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
                return true; /* ? */
        }
        
+       function getTableName() {
+               return $this->table;
+       }
+       
        function _query($sql) {
                $reps = func_get_args();
-               $reps[0] = $this->table;
+               $reps[0] = $this->getTableName();
                // ewwww
                for($i=0;$i<count($reps);$i++) {
                        $sql = str_replace(
@@ -302,7 +326,13 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
        }
 }
 
+/**
+ * @todo document
+ * @package MediaWiki
+ */
 class MediaWikiBagOStuff extends SqlBagOStuff {
+       var $tableInitialised = false;
+
        function _doquery($sql) {
                $dbw =& wfGetDB( DB_MASTER );
                return $dbw->query($sql, 'MediaWikiBagOStuff:_doquery');
@@ -329,8 +359,20 @@ class MediaWikiBagOStuff extends SqlBagOStuff {
                $dbw =& wfGetDB( DB_MASTER );
                return $dbw->strencode($s);
        }
+       function getTableName() {
+               if ( !$this->tableInitialised ) {
+                       $dbw =& wfGetDB( DB_MASTER );
+                       $this->table = $dbw->tableName( $this->table );
+                       $this->tableInitialised = true;
+               }
+               return $this->table;
+       }
 }
 
+/**
+ * @todo document
+ * @package MediaWiki
+ */
 class TurckBagOStuff extends BagOStuff {
        function get($key) {
                return mmcache_get( $key );