Mecha CMS

Cache::hit()

Update cache value automatically on every file update.

2.2.0Static

Cache::hit(string $file, callable $fn);
Cache::hit(array $files, callable $fn);

Example:

$cache = Cache::hit('.\path\to\file.php', function($file) {
    ob_start();
    require $file;
    return ob_get_clean();
});

$cache = Cache::hit([
    '.\path\to\file-1.php',
    '.\path\to\file-2.php',
    '.\path\to\file-3.php',
    '.\path\to\file-4.php'
], function($files) {
    $out = [];
    foreach ($files as $file) {
        $out = array_replace($out, require $file);
    }
    return $out;
});