<commit_before><?php
require_once 'Vps/Config/Ini.php';

class Vps_Config_Web extends Vps_Config_Ini
{
    static private $_instances = array();
    public static function getInstance($section)
    {
        if (!isset(self::$_instances[$section])) {
            require_once 'Vps/Config/Cache.php';
            $cache = Vps_Config_Cache::getInstance();
            $cacheId = 'config_'.str_replace('-', '_', $section);
            $configClass = Vps_Setup::$configClass;
            require_once str_replace('_', '/', $configClass).'.php';
            if(!$ret = $cache->load($cacheId)) {
                $ret = new $configClass($section);
                $mtime = time();
                $cache->save($ret, $cacheId);
            }
            self::$_instances[$section] = $ret;
        }
        return self::$_instances[$section];
    }

    public static function clearInstances()
    {
        self::$_instances = array();
    }

    public static function getInstanceMtime($section)
    {
        require_once 'Vps/Config/Cache.php';
        $cache = Vps_Config_Cache::getInstance();
        return $cache->test('config_'.str_replace('-', '_', $section));
    }

    public function __construct($section, $options = array())
    {
        if (isset($options['vpsPath'])) {
            $vpsPath = $options['vpsPath'];
        } else {
            $vpsPath = VPS_PATH;
        }
        if (isset($options['webPath'])) {
            $webPath = $options['webPath'];
        } else {
            $webPath = '.';
        }
<commit_msg>cache config in apc if possible<commit_after><?php
require_once 'Vps/Config/Ini.php';

class Vps_Config_Web extends Vps_Config_Ini
{
    static private $_instances = array();
    public static function getInstance($section)
    {
        if (!isset(self::$_instances[$section])) {
            $cacheId = 'config_'.str_replace('-', '_', $section);
            $configClass = Vps_Setup::$configClass;
            require_once str_replace('_', '/', $configClass).'.php';
            if (extension_loaded('apc')) {
                $cacheId .= getcwd();
                $ret = apc_fetch($cacheId);
                if ($ret && $ret->debug->componentCache->checkComponentModification) {
                    $masterFiles = array(
                        'application/config.ini',
                        VPS_PATH . '/config.ini'
                    );
                    if (file_exists('application/vps_branch')) $masterFiles[] = 'application/vps_branch';
                    $mtime = apc_fetch($cacheId.'mtime');
                    foreach ($masterFiles as $f) {
                        if (filemtime($f) > $mtime) {
                            $ret = false;
                            break;
                        }
                    }
                }
                if (!$ret) {
                    $ret = new $configClass($section);
                    apc_add($cacheId, $ret);
                    apc_add($cacheId.'mtime', time());
                }
            } else {
                require_once 'Vps/Config/Cache.php';
                $cache = Vps_Config_Cache::getInstance();
                if(!$ret = $cache->load($cacheId)) {
                    $ret = new $configClass($section);
                    $mtime = time();
                    $cache->save($ret, $cacheId);
                }
            }
            self::$_instances[$section] = $ret;
        }
        return self::$_instances[$section];
    }

    public static function clearInstances()
    {
        self::$_instances = array();
    }

    public static function getInstanceMtime($section)
    {
        if (extension_loaded('apc')) {
            $cacheId = 'config_'.str_replace('-', '_', $section);
            $cacheId .= getcwd();
            return apc_fetch($cacheId.'mtime');
        } else {
            require_once 'Vps/Config/Cache.php';
            $cache = Vps_Config_Cache::getInstance();
            return $cache->test('config_'.str_replace('-', '_', $section));
        }
    }

    public function __construct($section, $options = array())
    {
        if (isset($options['vpsPath'])) {
            $vpsPath = $options['vpsPath'];
        } else {
            $vpsPath = VPS_PATH;
        }
        if (isset($options['webPath'])) {
            $webPath = $options['webPath'];
        } else {
            $webPath = '.';
        }

{'fraction_non_alphanumeric': 0.14818202606906014, 'fraction_numerical': 0.0, 'mean_word_length': 1.6752293577981652, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7175797', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1211, 'n_words': 209}