PHP code example of bnomei / kirby-nitro

1. Go to this page and download the library: Download bnomei/kirby-nitro library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bnomei / kirby-nitro example snippets


class DefaultPage extends \Kirby\Cms\Page
{
    use \Bnomei\ModelWithNitro;
}

class ArticlePage extends \Kirby\Cms\Page
{
    use \Bnomei\ModelWithNitro;
}

nitro()->cache()->set('mykey', 'value');
nitro()->cache()->set('mykey', 'value', 1);

$value = nitro()->cache()->get('mykey');
$value = nitro()->cache()->getOrSet('mykey', fn() => 'value');

nitro()->cache()->set(['articles', $page->slug()], $page->title());

nitro()->cache()->set('test', function () {
    // ... some logic
    if($cancel) {
        throw new \Bnomei\Nitro\AbortCachingExeption();
    }
});

return [
    // ... other options
    
    // use nitro as cache driver for storing uuids
    // instead of the default file-based cache
    'cache' => [
        'uuid' => [
            'type' => 'nitro',
        ],
    ],
    
    // example: in Lapse plugin
    'bnomei.lapse.cache' => [
        'type' => 'nitro',
    ],
];