Sorry, we don't support your browser.  Install a modern browser
This post is closed.

add cache remember function

?

for kirbys base cache class a function called remember could be added that makes the common usecase of only fetching a value from cache if its null easier. this is done using a simple closure.

in laravel
https://github.com/laravel/framework/blob/ef99cffd4938759cecfe2cb19888e9ff3e942b87/src/Illuminate/Session/Store.php#L305

basically thats the main idea for my lapse plugin as well (with some more magic for the key generator).
https://github.com/bnomei/kirby3-lapse

$data = lapse(crc32($page->url()), function () use ($kirby, $site, $page) {
    // create some data
    return [
        'author' => site()->author(),
        'title' => $page->title(),
        'text' => $page->text()->kirbytext(),
        'url' => $page->url(),
    ];
});
  • bnomei
3 years ago
2 years ago
Changed the status to
Completed
2 years ago