Mecha CMS

Cache::set()

Create a new cache file.

2.0.0 Static

Cache::set(string $id, callable $fn, array $lot = []): array;

Example:

$A = Cache::set('foo', function() {
    return date('Y-m-d H:i:s');
});

$B = Cache::set($f = '.\lot\path\to\file.php', function() use($f) {
    ob_start();
    require $f;
    return ob_get_clean();
});

Result:

$A = ['2021-12-04 15:40:54', '.\lot\cache\8c736521.php', 1549080564];
$B = ['Content of file.php', '.\lot\cache\path\to\file.php.php', 1549080564];