[limb-svn] r6003 - 3.x/trunk/limb/dbal/src/drivers

svn at limb-project.com svn at limb-project.com
Wed Jun 20 01:11:23 MSD 2007


Author: pachanga
Date: 2007-06-20 01:11:23 +0400 (Wed, 20 Jun 2007)
New Revision: 6003
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6003

Modified:
   3.x/trunk/limb/dbal/src/drivers/lmbDbCachedInfo.class.php
Log:
-- database meta information cache is off by default

Modified: 3.x/trunk/limb/dbal/src/drivers/lmbDbCachedInfo.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/lmbDbCachedInfo.class.php	2007-06-19 21:09:36 UTC (rev 6002)
+++ 3.x/trunk/limb/dbal/src/drivers/lmbDbCachedInfo.class.php	2007-06-19 21:11:23 UTC (rev 6003)
@@ -1,105 +1,105 @@
-<?php
+<?php
 /*
  * Limb PHP Framework
  *
  * @link http://limb-project.com 
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
- */
-lmb_require('limb/core/src/lmbSerializable.class.php');
-lmb_require('limb/core/src/lmbProxy.class.php');
+ */
+lmb_require('limb/core/src/lmbSerializable.class.php');
+lmb_require('limb/core/src/lmbProxy.class.php');
 lmb_require('limb/fs/src/lmbFs.class.php');
 
-/**
- * class lmbDbCachedInfo.
- *
- * @package dbal
- * @version $Id$
+/**
+ * class lmbDbCachedInfo.
+ *
+ * @package dbal
+ * @version $Id$
  */
-class lmbDbCachedInfo extends lmbProxy
-{
-  protected $conn;
-  protected $db_info;
-  protected $cache_file;
-
-  function __construct($conn, $cache_dir = null)
-  {
-    $this->conn = $conn;
-    if($cache_dir)
-      $this->cache_file = $cache_dir . '/db_info.' . $conn->getHash() . '.cache';
-  }
-
-  function flushCache()
-  {
-    if($this->cache_file && file_exists($this->cache_file))
-      unlink($this->cache_file);
-  }
-
-  protected function _createOriginalObject()
-  {
-    if($db_info = $this->_readFromCache())
-      return $db_info;
-
-    //forcing to load all metainfo
-    $db_info = $this->conn->getDatabaseInfo();
-    $tables = $db_info->getTableList();
-    foreach($tables as $table)
-      $db_info->getTable($table)->loadColumns();
-
-    $this->_writeToCache($db_info);
-    return $db_info;
-  }
-
-  protected function _readFromCache()
-  {
-    if($db_info = $this->_readFromMemCache())
-      return $db_info;
-
-    if($db_info = $this->_readFromFileCache())
-    {
-      $this->_writeToMemCache($db_info);
-      return $db_info;
-    }
-  }
-
-  protected function _readFromMemCache()
-  {
-    if(isset($this->db_info))
-      return $this->db_info;
-  }
-
-  protected function _readFromFileCache()
-  {
-    if($this->_isFileCachingEnabled() && file_exists($this->cache_file))
-    {
-      $container = unserialize(file_get_contents($this->cache_file));
-      $db_info = $container->getSubject();
-      return $db_info;
-    }
-  }
-
-  protected function _writeToCache($db_info)
-  {
-    $this->_writeToMemCache($db_info);
-    $this->_writeToFileCache($db_info);
-  }
-
-  protected function _writeToMemCache($db_info)
-  {
-    $this->db_info = $db_info;
-  }
-
-  protected function _writeToFileCache($db_info)
-  {
-    if($this->_isFileCachingEnabled())
-      lmbFs :: safeWrite($this->cache_file, serialize(new lmbSerializable($db_info)));
-  }
-
-  protected function _isFileCachingEnabled()
-  {
-    return ($this->cache_file &&
-            (!defined('LIMB_CACHE_DB_META_IN_FILE') || constant('LIMB_CACHE_DB_META_IN_FILE')));
-  }
-}
-
-?>
+class lmbDbCachedInfo extends lmbProxy
+{
+  protected $conn;
+  protected $db_info;
+  protected $cache_file;
+
+  function __construct($conn, $cache_dir = null)
+  {
+    $this->conn = $conn;
+    if($cache_dir)
+      $this->cache_file = $cache_dir . '/db_info.' . $conn->getHash() . '.cache';
+  }
+
+  function flushCache()
+  {
+    if($this->cache_file && file_exists($this->cache_file))
+      unlink($this->cache_file);
+  }
+
+  protected function _createOriginalObject()
+  {
+    if($db_info = $this->_readFromCache())
+      return $db_info;
+
+    //forcing to load all metainfo
+    $db_info = $this->conn->getDatabaseInfo();
+    $tables = $db_info->getTableList();
+    foreach($tables as $table)
+      $db_info->getTable($table)->loadColumns();
+
+    $this->_writeToCache($db_info);
+    return $db_info;
+  }
+
+  protected function _readFromCache()
+  {
+    if($db_info = $this->_readFromMemCache())
+      return $db_info;
+
+    if($db_info = $this->_readFromFileCache())
+    {
+      $this->_writeToMemCache($db_info);
+      return $db_info;
+    }
+  }
+
+  protected function _readFromMemCache()
+  {
+    if(isset($this->db_info))
+      return $this->db_info;
+  }
+
+  protected function _readFromFileCache()
+  {
+    if($this->_isFileCachingEnabled() && file_exists($this->cache_file))
+    {
+      $container = unserialize(file_get_contents($this->cache_file));
+      $db_info = $container->getSubject();
+      return $db_info;
+    }
+  }
+
+  protected function _writeToCache($db_info)
+  {
+    $this->_writeToMemCache($db_info);
+    $this->_writeToFileCache($db_info);
+  }
+
+  protected function _writeToMemCache($db_info)
+  {
+    $this->db_info = $db_info;
+  }
+
+  protected function _writeToFileCache($db_info)
+  {
+    if($this->_isFileCachingEnabled())
+      lmbFs :: safeWrite($this->cache_file, serialize(new lmbSerializable($db_info)));
+  }
+
+  protected function _isFileCachingEnabled()
+  {
+    return ($this->cache_file &&
+            (defined('LIMB_CACHE_DB_META_IN_FILE') && constant('LIMB_CACHE_DB_META_IN_FILE')));
+  }
+}
+
+?>



More information about the limb-svn mailing list