[pLog-svn] r3159 - in plog/trunk/class: cache dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Mar 29 20:54:03 GMT 2006


Author: oscar
Date: 2006-03-29 20:54:03 +0000 (Wed, 29 Mar 2006)
New Revision: 3159

Modified:
   plog/trunk/class/cache/cachemanager.class.php
   plog/trunk/class/dao/model.class.php
Log:
the toggle to enable or disable the data cache is working again


Modified: plog/trunk/class/cache/cachemanager.class.php
===================================================================
--- plog/trunk/class/cache/cachemanager.class.php	2006-03-29 17:51:52 UTC (rev 3158)
+++ plog/trunk/class/cache/cachemanager.class.php	2006-03-29 20:54:03 UTC (rev 3159)
@@ -18,7 +18,14 @@
             $cacheInstance->clearCache();
         }
 
-        function &getCache()
+		/**
+		 * Returns an instance of the cache.
+		 *
+		 * @param cacheEnabled Set this to false if you wish this class to always return no data,
+		 * meaning that it will have to be loaded every time.
+		 * @return The global instance of the Cache_Lite class
+		 */
+        function &getCache( $cacheEnabled = true )
         {
             static $cache;
 
@@ -33,7 +40,8 @@
                     'lifeTime' => 604800,
                     'readControl' => false,
                     'automaticSerialization' => true,
-                    'hashedDirectoryLevel' => 2
+                    'hashedDirectoryLevel' => 2,
+					'caching' => $cacheEnabled
                 );
 
                 // build a new cache object
@@ -44,8 +52,8 @@
 
         function disableCache( $category )
         {
-            $cache = CacheManager::getCache();
+            $cache =& CacheManager::getCache();
             $cache->disableCacheForCategory( $category );
         }
     }
-?>
+?>
\ No newline at end of file

Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php	2006-03-29 17:51:52 UTC (rev 3158)
+++ plog/trunk/class/dao/model.class.php	2006-03-29 20:54:03 UTC (rev 3159)
@@ -63,6 +63,11 @@
      * whether we're going to use paging or not.
      */
     define( "DEFAULT_PAGING_ENABLED", -1 );
+	
+	/**
+	 * enable or disable the data cache
+	 */
+	define( "DATA_CACHE_ENABLED", true );
 
     /**
      * the names of the tables used in pLog
@@ -96,15 +101,13 @@
          *
          * @param useCache Some object might not need a cache and can disable it by passing false
          */
-        function Model( $useCache = true )
+        function Model( $cacheEnabled = DATA_CACHE_ENABLED )
         {
             $this->Loggable();
 
-            if ( $useCache ) {
-                // allow a cache for all dao objects
-                include_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
-                $this->_cache =& CacheManager::getCache();
-            }
+            // allow a cache for all dao objects
+            include_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
+            $this->_cache =& CacheManager::getCache( $cacheEnabled );
         }
 
         /**



More information about the pLog-svn mailing list