Skip to content

Commit

Permalink
Updated Kohana_Cache to use the global Kohana::$caching setting by de…
Browse files Browse the repository at this point in the history
…fault, and using the standard cache naming system
  • Loading branch information
Woody Gilk committed Jun 13, 2009
1 parent ab38cfe commit 6cef70a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions system/classes/kohana/config.php
Expand Up @@ -9,9 +9,6 @@
*/
class Kohana_Config_Core extends ArrayObject {

// Cache prefix string
const CACHE_PREFIX = 'kohana_configuration_';

/**
* Loads all of the files in a configuration group and returns a merged
* array of the values.
Expand Down Expand Up @@ -50,23 +47,35 @@ protected static function load($group)
* @param boolean cache the group array
* @return void
*/
public function __construct($group, $cache = TRUE)
public function __construct($group, $cache = NULL)
{
// Set the configuration group name
$this->_configuration_group = $group;

if ($cache === NULL)
{
// Use the global caching
$cache = Kohana::$cached;
}

if ($cache === FALSE)
{
// Load the configuration
$config = Kohana_Config::load($group);
}
elseif (($config = Kohana::cache(self::CACHE_PREFIX.$group)) === NULL)
else
{
// Load the configuration, it has not been cached
$config = Kohana_Config::load($group);
// Set the cache key
$cache_key = 'Kohana_Config::load("'.$group.'")';

if (($config = Kohana::cache($cache_key)) === NULL)
{
// Load the configuration, it has not been cached
$config = Kohana_Config::load($group);

// Create a cache of the configuration group
Kohana::cache(self::CACHE_PREFIX.$group, $config);
// Create a cache of the configuration group
Kohana::cache($cache_key, $config);
}
}

// Load the array using the values as properties
Expand Down

0 comments on commit 6cef70a

Please sign in to comment.