<commit_before><?php

if ( ! function_exists('cache') )
{
    function cache($key, Closure $closure)
    {
        $content = Cache::get($key);
        if ( ! $content ) {
            ob_start();
            
            $closure();
            $content = ob_get_contents();
            ob_end_clean();
            Cache::forever($key, $content);
            Log::debug('writing cache', [$key]);
        } else {
            Log::debug('reading cache', [$key]);
        }

        return $content;
    }
}<commit_msg>Add an optional second parameter to cache, used to conditionaly enable/disable caching<commit_after><?php

if ( ! function_exists('cache') )
{
    function cache($key, $condition = true, Closure $closure)
    {
        $content = $condition ? Cache::get($key) : false;
        if ( ! $content ) {
            ob_start();
            
            $closure();
            $content = ob_get_contents();
            ob_end_clean();
	    if ($condition) {
		    Cache::forever($key, $content);
		    Log::debug('writing cache', [$key]);
	    }
        } else {
            Log::debug('reading cache', [$key]);
        }

        return $content;
    }
}
{'fraction_non_alphanumeric': 0.15536480686695278, 'fraction_numerical': 0.0, 'mean_word_length': 1.857843137254902, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '712325', 'n_tokens_mistral': 345, 'n_tokens_neox': 327, 'n_words': 71}