Changeset 2718

Show
Ignore:
Timestamp:
05/29/2008 04:18:31 PM (6 months ago)
Author:
Shadowhand
Message:

Follow up to r2716, writing caches on-the-fly is faster than using Events.

Location:
trunk/system/core
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/core/Config.php

    r2716 r2718  
    1717        // Cached configuration 
    1818        private static $cache; 
    19         private static $cache_changed = FALSE; 
    2019 
    2120        // Include paths 
     
    134133        public static function clear($key) 
    135134        { 
    136                 if (isset($cache[$key])) 
    137                 { 
    138                         // Cache has been changed 
    139                         self::$cache_changed = TRUE; 
    140                 } 
    141  
    142135                unset(self::$conf[$key], self::$cache[$key]); 
     136 
     137                // Save updated cache 
     138                Kohana::save_cache('configuration', self::$cache); 
    143139 
    144140                return TRUE; 
     
    220216                } 
    221217 
    222                 if (self::$cache_changed === FALSE AND (bool) Config::item('core.internal_cache')) 
    223                 { 
    224                         // Write the caches on shutdown 
    225                         Event::add('system.shutdown', array('Config', 'save_cache')); 
    226                 } 
    227  
    228                 // Cache has been changed 
    229                 self::$cache_changed = TRUE; 
     218                // Save updated cache 
     219                Kohana::save_cache('configuration', self::$cache); 
    230220 
    231221                // Cache the configuration 
     
    233223        } 
    234224 
    235         /** 
    236          * Writes configuration caches, typically called during shutdown. 
    237          * 
    238          * @return  bool 
    239          */ 
    240         public static function save_cache() 
    241         { 
    242                 if (self::$cache_changed === TRUE) 
    243                 { 
    244                         // Write caches 
    245                         return Kohana::save_cache('configuration', self::$cache); 
    246                 } 
    247         } 
    248  
    249225} // End Config 
  • trunk/system/core/Kohana.php

    r2716 r2718  
    2929        // File path cache 
    3030        private static $paths; 
    31         private static $paths_changed = FALSE; 
    3231 
    3332        /** 
     
    811810                } 
    812811 
    813                 if (self::$paths_changed === FALSE AND (bool) Config::item('core.internal_cache')) 
    814                 { 
    815                         // Write the caches on shutdown 
    816                         Event::add('system.shutdown', array('Kohana', 'save_paths')); 
    817                 } 
    818  
    819                 // Paths have been changed 
    820                 self::$paths_changed = TRUE; 
     812                // Save updated cache 
     813                Kohana::save_cache('file_paths', self::$paths); 
    821814 
    822815                return self::$paths[$search] = $found; 
    823         } 
    824  
    825         /** 
    826          * Writes file path caches, typically called during shutdown. 
    827          * 
    828          * @return  bool 
    829          */ 
    830         public static function save_paths() 
    831         { 
    832                 if (self::$paths_changed === TRUE) 
    833                 { 
    834                         // Write caches 
    835                         return Kohana::save_cache('file_paths', self::$paths); 
    836                 } 
    837816        } 
    838817