[pLog-svn] r2200 - plog/trunk/class/cache

ork at devel.plogworld.net ork at devel.plogworld.net
Sat Jun 11 22:04:29 GMT 2005


Author: ork
Date: 2005-06-11 22:04:29 +0000 (Sat, 11 Jun 2005)
New Revision: 2200

Modified:
   plog/trunk/class/cache/cache.class.php
Log:
added proper debug messages


Modified: plog/trunk/class/cache/cache.class.php
===================================================================
--- plog/trunk/class/cache/cache.class.php	2005-06-11 22:03:49 UTC (rev 2199)
+++ plog/trunk/class/cache/cache.class.php	2005-06-11 22:04:29 UTC (rev 2200)
@@ -1,7 +1,6 @@
 <?php
 
     require_once( PLOG_CLASS_PATH . "class/object/object.class.php" );
-    require_once( PLOG_CLASS_PATH . "class/cache/Cache_Lite/Lite.php" );
 
    /**
     * Provides a singleton for storing and retrieving data from a global cache.
@@ -13,40 +12,53 @@
 
         function Cache( $cacheProperties )
         {
+            require_once( PLOG_CLASS_PATH . "class/cache/Cache_Lite/Lite.php" );
+
             $this->Object();
             $this->cache = new Cache_Lite( $cacheProperties );
         }
 
         function setData( $id, $group, $data )
         {
-            $this->log->info("Caching $id ($group):" . $data );
+            // Debug message, if debug enabled and debug channel cache activated
+            if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
+                $this->debug->log("Caching $id ($group):" . $data , LOGGER_PRIO_INFO );
             return $this->cache->save( $data, $id, $group );
         }
 
         function getData( $id, $group )
         {
             $inCache = $this->cache->get( $id, $group );
-            if ($inCache) {
-                $this->log->info("Cache hit for $id ($group):" . $data );
-            } else {
-                $this->log->info("Cache miss for $id ($group)" );
-            }
+            if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
+                if ($inCache)
+                    $this->debug->log("Cache hit for $id ($group): $data", LOGGER_PRIO_INFO );
+                else
+                    $this->debug->log("Cache miss for $id ($group)", LOGGER_PRIO_WARN );
+
             return $inCache;
         }
 
         function removeData( $id, $group )
         {
-            $this->log->info("Removing from cache $id ($group)" );
+            if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
+                $this->debug->log("Removing from cache $id ($group)", LOGGER_PRIO_WARN );
+
             return $this->cache->remove( $id, $group );
         }
 
         function clearCacheByGroup( $group )
         {
+            if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
+                $this->debug->log("Removing cache group: $group", LOGGER_PRIO_WARN );
+
             return $this->cache->clean( $group );
         }
 
         function clearCache()
         {
+            if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
+                $this->debug->warn("Cleaning the cache" );
+
             return $this->cache->clean();
         }
 




More information about the pLog-svn mailing list