Mecha CMS

Cache::live()

Update cache value automatically every time the expiration period is reached.

2.2.0 Static

Cache::live(string $id, callable $fn, int $for = 86400);
Cache::live(string $id, callable $fn, string $for = '1 day');

Example:

$cache = Cache::live('foo', function() {
    return date('Y-m-d H:i:s');
}, '1 day');

$cache = Cache::live($f = '.\path\to\file.php', function() use($f) {
    ob_start();
    require $f;
    return ob_get_clean();
}, '1 day');